`
public class TeamView {
private NameListService listSvc= new NameListService();
private TeamView teamSvc=new TeamView();
public static void main(String[] args) {
TeamView view = new TeamView();
view.enterMainMenu();
}
}
//在myproject03的TeamView类中,成员变量这里new错了对象,new成了自己,主函数那里又new了一次。 导致套娃,堆中一直new,栈中变量也一直增加,最终出现 StackOverflowError。
Exception in thread "main" java.lang.StackOverflowError
at java.io.FileOutputStream.write(FileOutputStream.java:326)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
at java.io.PrintStream.write(PrintStream.java:482)
at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:221)
at sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:291)
at sun.nio.cs.StreamEncoder.flushBuffer(StreamEncoder.java:104)
at java.io.OutputStreamWriter.flushBuffer(OutputStreamWriter.java:185)
at java.io.PrintStream.write(PrintStream.java:527)
at java.io.PrintStream.print(PrintStream.java:639)
at java.io.PrintStream.println(PrintStream.java:778)
at com.atguigu.team.service.NameListService.createEquipment(NameListService.java:83)
at com.atguigu.team.service.NameListService.<init>(NameListService.java:56)
at com.atguigu.team.view.TeamView.<init>(TeamView.java:9)
at com.atguigu.team.view.TeamView.<init>(TeamView.java:10)
at com.atguigu.team.view.TeamView.<init>(TeamView.java:10)
at com.atguigu.team.view.TeamView.<init>(TeamView.java:10)
at com.atguigu.team.view.TeamView.<init>(TeamView.java:10)
at com.atguigu.team.view.TeamView.<init>(TeamView.java:10)
at com.atguigu.team.view.TeamView.<init>(TeamView.java:10)
at com.atguigu.team.view.TeamView.<init>(TeamView.java:10)
at com.atguigu.team.view.TeamView.<init>(TeamView.java:10)
at com.atguigu.team.view.TeamView.<init>(TeamView.java:10)
at com.atguigu.team.view.TeamView.<init>(TeamView.java:10)
at com.atguigu.team.view.TeamView.<init>(TeamView.java:10)
at com.atguigu.team.view.TeamView.<init>(TeamView.java:10)
at com.atguigu.team.view.TeamView.<init>(TeamView.java:10)
at com.atguigu.team.view.TeamView.<init>(TeamView.java:10)
at com.atguigu.team.view.TeamView.<init>(TeamView.java:10)
at com.atguigu.team.view.TeamView.<init>(TeamView.java:10)
at com.atguigu.team.view.TeamView.<init>(TeamView.java:10)
at com.atguigu.team.view.TeamView.<init>(TeamView.java:10)
at com.atguigu.team.view.TeamView.<init>(TeamView.java:10)
at com.atguigu.team.view.TeamView.<init>(TeamView.java:10)
at com.atguigu.team.view.TeamView.<init>(TeamView.java:10)
at com.atguigu.team.view.TeamView.<init>(TeamView.java:10)
at com.atguigu.team.view.TeamView.<init>(TeamView.java:10)
at com.atguigu.team.view.TeamView.<init>(TeamView.java:10)
at com.atguigu.team.view.TeamView.<init>(TeamView.java:10)
at com.atguigu.team.view.TeamView.<init>(TeamView.java:10)
at com.atguigu.team.view.TeamView.<init>(TeamView.java:10)
at com.atguigu.team.view.TeamView.<init>(TeamView.java:10)
at com.atguigu.team.view.TeamView.<init>(TeamView.java:10)
at com.atguigu.team.view.TeamView.<init>(TeamView.java:10)
at com.atguigu.team.view.TeamView.<init>(TeamView.java:10)