package J20250718.demo02_exception; /** * @author WanJl * @version 1.0 * @title Demo01 * @description * @create 2025/7/18 */ public class Demo01 { public static void method666(){ method666(); //方法调用自身---方法的递归,方法调用自身层数太多就容易出现栈内存溢出错误 System.out.println("hello......"); System.out.println("hello......"); System.out.println("hello......"); System.out.println("hello......"); } public static void main(String[] args) { //异常1-数组下标越界异常 int[] arr=new int[3]; //System.out.println(arr[4]); //ArrayIndexOutOfBoundsException //异常2-除零异常 //System.out.println(5/0); //ArithmeticException //异常3-类型转换异常 //Fu f=new Zi1(); //Zi2 z2=(Zi2) f; //ClassCastException //int[] arr2=new int[1024*1024*1024]; //OutOfMemoryError method666(); //StackOverflowError } } class Fu{ } class Zi1 extends Fu{ } class Zi2 extends Fu{ }