Java简单反射实例,java实例,Java简单反射实例:[
分享于 点击 18413 次 点评:166
Java简单反射实例,java实例,Java简单反射实例:[
Java简单反射实例:
[Java]代码
package com.just;import java.lang.reflect.InvocationTargetException;import java.lang.reflect.Method;//简单的反射demopublic class Test { public void printf(){ System.out.println("hhh"); } public static void main(String[] args) throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, InstantiationException { Class c = Class.forName("com.just.Test"); Method m = c.getDeclaredMethod("printf",null); m.invoke(c.newInstance(),null); }}
用户点评