constructortroubleaccess.java
来自「JAVA 工作指南 可以说是程序员必备的东西哦」· Java 代码 · 共 29 行
JAVA
29 行
import java.lang.reflect.Constructor;import java.lang.reflect.InvocationTargetException;class Deny { private Deny() { System.out.format("Deny constructor%n"); }}public class ConstructorTroubleAccess { public static void main(String... args) { try { Constructor c = Deny.class.getDeclaredConstructor();// c.setAccessible(true); // solution c.newInstance(); // production code should handle these exceptions more gracefully } catch (InvocationTargetException x) { x.printStackTrace(); } catch (NoSuchMethodException x) { x.printStackTrace(); } catch (InstantiationException x) { x.printStackTrace(); } catch (IllegalAccessException x) { x.printStackTrace(); } }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?