在给你补充一个静态访问非静态的方式:通过反射
public static void main(String[] args) throws SecurityException, Exception {
Test14 t = new Test14();
Method showMethod = Test14.class.getMethod("show");
System.out.println(showMethod.invoke(t));
}
public String show()
{
return "hello";
} |
|