Java学习第32天

综合实例

模拟不可恢复错误的异常(程序的异常不可恢复)

package helloworld;
import java.util.Scanner;
/**
 * 不可恢复错误演示
 *
 */
public class study{
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        while(true) {
            System.out.print("1 堆溢出   2 栈溢出:");
            String str=in.nextLine();
            if(str.equals("1")) {
                char[] chs=new char[0x7fffffff];
            }else if(str.equals("2")) {
                f();
            }
        }
    }
    public static void f() {
        f();
    }
}

二、问题

无法出现堆栈

三、明日开第十二章I/O流

posted @ 2020-08-06 20:05  居酿圆子  阅读(63)  评论(0编辑  收藏  举报