reflect最简单的例子

package test;

public interface CountInterface {

	public int add(int a, int b);
	
	public int subtraction(int a, int b);
	
	public int multiplication(int a, int b);
}
 
package test;

import java.lang.reflect.Method;

public class Test {

	public static void main(String[] args) {

		Method[] methods = CountInterface.class.getMethods();
		for(Method m : methods){
			System.out.println(m.getName());
		}
			
	}
}
subtraction
multiplication
add
 

 Notice :两个文件在同一个包下

你可能感兴趣的:(reflect demo)