【发布时间】:2017-09-19 05:43:27
【问题描述】:
我在 Netbeans 中创建了一个 java 项目,如下所示,但运行后出现错误消息:
public class Outer {
static class NestedDemo{
public void MyMethod(){
System.out.println("This is my nested class");
}
}
public static void main(String args[]){
Outer.NestedDemo nested=Outer.new NestedDemo();
nested.MyMethod();
}
}
错误是这样的:
java.lang.VerifyError: Constructor must call super() or this() before return in method array.newpackage.newpackage.Outer.<init>()V at offset 0
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2451)
at java.lang.Class.getMethod0(Class.java:2694)
at java.lang.Class.getMethod(Class.java:1622)
at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)
Exception in thread "main" Java Result: 1
BUILD SUCCESSFUL (total time: 2 seconds)
有什么问题?
【问题讨论】:
标签: static-classes