
异常
谭小布偶
这个作者很懒,什么都没留下…
展开
-
回顾+重新认识异常
什么是异常?在Java程序运行过程,常常会发生一些非正常的现象,这类情况被称为运行错误。根据其性质可以分为异常和错误。在Java程序中,所有抛出(throw)的异常都需要经过Throwable派生而来,类Throwable有两个子类(Errow和Exception)异常关键字Java异常的关键字有try,catch,finally,throw,throws.(1)try,cattch,finally是搭配使用,不能单独存在,可以是①try…catch…,②try…catch…finally…,③tr原创 2021-08-04 14:12:18 · 86 阅读 · 0 评论 -
异常
认识异常1.除以0public static void main(String[] args) { System.out.println(10/0); }2.数组下标越界public static void main(String[] args) { int[] arr = new int[]{1,2,3}; System.out.println(arr[4]); }3.访问null(空指针异常) public static原创 2021-04-24 20:28:03 · 92 阅读 · 0 评论