public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
String string = sc.nextLine();
Class c = Class.forName("heima.mianshiti.A");// 获取字节码对象
Method m = c.getMethod("showString", String.class);
m.invoke(c.newInstance(), string);
}
}
class A {
public void showString(String str) {
System.out.println(str);
}
}
|
|