!~@#

做个测试:public static void main(String args) {new Test();try {Test.class.newInstance(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); }}public static class Test{private Test(){System.out.println("test!"); }}你们猜猜看结果如何?test!java.lang.IllegalAccessException: Class http://xxx.xxx can not access a member of class http://xxx.xxx$Test with modifiers "private" at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:101) at java.lang.Class.newInstance(Class.java:427) at xxx.xxx.main(xxx.java:221)
■网友
没什么本质区别,你可以用SPRING或者写个静态方法
■网友
遇事不决先谷歌


    推荐阅读