51,410
社区成员
发帖
与我相关
我的任务
分享
import java.lang.reflect.Method;
public class Main {
public interface Tester {}
public static Tester create() {
return new Tester() {
public void test() {
System.out.println("测试");
}
};
}
public static void main(String[] args) throws Exception {
Tester tester = create();
Method method = tester.getClass().getMethod("test");
method.invoke(tester);
}
}