【发布时间】:2014-12-04 10:29:30
【问题描述】:
我在构造函数之后创建了一个对象 d,然后在 main 方法中创建了另一个对象 f。我需要了解为什么 Output 会给出例外 (Exception in thread "main" java.lang.StackOverflowError)。但是,如果我没有在构造函数之后创建对象 d,则程序会成功运行。
public class OuterTwo {
public OuterTwo() {
System.out.println("OUTER!");
}
OuterTwo d = new OuterTwo();
public static void main(String[] args) {
OuterTwo f = new OuterTwo();
}
}
【问题讨论】:
-
我也将感谢一个关于 JAVA 嵌套类的编写和解释良好的教程的来源。
-
这里没有看到任何嵌套类
标签: java class constructor call