s-day05--异常产生的原因以及流程
This commit is contained in:
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user