今天爱分享给大家带来java 编写栈内存溢出异常程序【附代码】,希望能够帮助到大家。
public class StackOverFlow {
private int i;
public void plus() {
i++;
plus();
}
public static void main(String[] args) {
StackOverFlow stackOverFlow = new StackOverFlow();
try {
stackOverFlow.plus();
} catch (Error e) {
System.out.println("Error:stack length:" + stackOverFlow.i);
e.printStackTrace();
}
}
}
原文链接:https://blog.itblood.com/912.html,转载请注明出处。
