diff --git a/s-day05/src/com/inmind/exception01/Demo02.java b/s-day05/src/com/inmind/exception01/Demo02.java new file mode 100644 index 0000000..e4924dc --- /dev/null +++ b/s-day05/src/com/inmind/exception01/Demo02.java @@ -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; + } +}