import java.lang.reflect.Method; public class ReflectionExample { public static void main(String[] args) throws Exception { Class<?> clazz = Class.forName("com.example.MyClass"); Object obj = clazz.newInstance(); Method method = clazz.getMethod("myMethod"); method.invoke(obj); } }


上一篇:
下一篇:
切换中文