Java异常的分类

学习笔记,转自:http://blog.csdn.net/ilibaba/article/details/3965359

----------------------------------------------------------------------------------------------------

1、  NullPointerException(值为空)

2、  NumberFormatException:继承IllegalArgumentException,字符串转换为数字时出现。比如int i= Integer.parseInt("ab3");

3、  ArrayIndexOutOfBoundsException:数组越界。比如 int[] a=new int[3]; int b=a[3];

4、  StringIndexOutOfBoundsException:字符串越界。比如 String s="hello"; char c=s.chatAt(6);

5、  ClassCastException:类型转换错误。比如 Object obj=new Object(); String s=(String)obj;

6、  UnsupportedOperationException:该操作不被支持。

7、  ArithmeticException:算术错误,典型的就是0作为除数的时候。

扫描二维码关注公众号,回复: 572410 查看本文章

8、  IllegalArgumentException:非法参数,在把字符串转换成数字的时候经常出现的一个异常

猜你喜欢

转载自fangdongyang.iteye.com/blog/1978257
今日推荐