Java入门——day22

一、今日学习

综合实例

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

 1 package helloworld;
 2 import java.util.Scanner;
 3 /**
 4  * 不可恢复错误演示
 5  *
 6  */
 7 public class study{
 8     public static void main(String[] args) {
 9         Scanner in=new Scanner(System.in);
10         while(true) {
11             System.out.print("1 堆溢出   2 栈溢出:");
12             String str=in.nextLine();
13             if(str.equals("1")) {
14                 char[] chs=new char[0x7fffffff];
15             }else if(str.equals("2")) {
16                 f();
17             }
18         }
19     }
20     public static void f() {
21         f();
22     }
23 }

 

二、遇到问题

编写有关异常的代码时仍然无从下手

三、明日学习

开始学习第十二章的内容

原文地址:https://www.cnblogs.com/znjy/p/13387931.html