📄 constructortest.java
字号:
/** * test that a class whose objects are instantiated via newInstance * do in fact have a default, no-arg constructor. If they don't, * an InstantiationException must be thrown. */public class ConstructorTest { public ConstructorTest(int i) {} public static void main(String[]argv) throws IllegalAccessException, InstantiationException { try { Object o = ConstructorTest.class.newInstance(); } catch (InstantiationException e) { System.out.println("Success."); return; } System.out.println("Failure."); }}/* Expected Output:Success.*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -