From 3ad7b7c2a20f4f7fb101fe5b403de46c639b6907 Mon Sep 17 00:00:00 2001 From: xuxin <840198532@qq.com> Date: Fri, 16 Oct 2026 10:16:03 +0800 Subject: [PATCH] =?UTF-8?q?s-day05--=E5=BC=82=E5=B8=B8=E7=9A=84=E7=BB=93?= =?UTF-8?q?=E6=9E=84=E4=BB=A5=E5=8F=8A=E5=BC=82=E5=B8=B8=E7=9A=84=E5=88=86?= =?UTF-8?q?=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/inmind/exception01/Demo01.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 s-day05/src/com/inmind/exception01/Demo01.java 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("程序结束"); + } +}