s-day05--异常产生的原因以及流程

This commit is contained in:
xx
2026-10-16 10:31:45 +08:00
parent 3ad7b7c2a2
commit 43cfd79d11
@@ -0,0 +1,19 @@
package com.inmind.exception01;
/*
异常产生的原因与流程
*/
public class Demo02 {
public static void main(String[] args) {
int[] arr = {1, 2, 3, 4, 5};
int result = getValue(arr, 8);
System.out.println(result);
System.out.println("程序结束");
}
private static int getValue(int[] arr, int index) {
int result = arr[index];//ArrayIndexOutOfBoundsException
return result;
}
}