diff --git a/s-day05/src/com/inmind/exception01/Demo01.java b/s-day05/src/com/inmind/exception01/Demo01.java new file mode 100644 index 0000000..2539f4e --- /dev/null +++ b/s-day05/src/com/inmind/exception01/Demo01.java @@ -0,0 +1,28 @@ +package com.inmind.exception01; +/* +异常:程序运行时,会产生的一些问题或者错误。 + +在java中有一个类专门来表示错误和异常,Throwable +Throwable类是Java语言中所有错误和异常的超类。 + Throwable分类: + 1.错误 Error,表示程序发生不可挽救的错误。 + 2.异常Exception,表示程序发生轻微问题,可以处理。 + +内存溢出:申请了超出了原本内存空间(16G)的更大的空间(20G) +内存泄漏:一个再也不需要使用的对象,占用了一块内存区域后,没有被释放,这就是泄漏 + */ +public class Demo01 { + public static void main(String[] args) { + //空指针异常 + /*int[] arr = null; + System.out.println(arr[0]);*/ + //错误:OutOfMemoryError内存溢出错误 + /*int[] arr1 = new int[10000*10000*100]; + int[] arr2 = new int[10000*10000*100]; + int[] arr3 = new int[10000*10000*100]; + int[] arr4 = new int[10000*10000*100]; + int[] arr5 = new int[10000*10000*100];*/ + + System.out.println("程序结束"); + } +}