示例代码: public class ExecDemo { public static void main(String[] args) { int[] nums = new int[4]; System.out.println(before the exception:); try { //try代码块 try catch代码块可以嵌套 try{ nums[7] = 10; //数组越界 System.out.println(no e
示例代码:
抛出异常:
重新抛出异常:
throws语句:一个方法产生自己不做处理的异常,用throws抛出到外层(谁调用,谁处理异常)
可以用一个catch()捕获多个异常:
自定义异常:
|
2021-06-05
2021-05-27
2021-05-26
2021-06-05
2021-05-16