首页 > 代码库 > java常见异常和错误

java常见异常和错误

异常

1.NumberFormatException  数字格式化异常

2.ArithmeticException 算术异常

3.ArrayIndexOutOfBoundsException  数组超出绑定异常:没有输入参数,或输入的参数不够

4.NullPointerException 空指针异常:使用了未实例化的对象

5.NoSuchMethodError:main  找不到主方法

6.ClassCastExeption:A 类转换异常

7.IllegalThreadStateException




错误:

1.integer number too large

2.name has private access in Person 无法访问封装属性

3.call to this must be first statement in constructor  错误的调用,只能放在构造方法的首行

4.recursive constructor invocation 递归调用了构造方法

5.non-static variable name cannot be referenced from a static context  不能调用非static属性

6.non-static method fun() cannot be referenced from a static context 不能调用非static方法

7.Singleton() has private access in Singleton 无法实例化

8.print() in Student cannot override print() int Person; attempting to assign weaker access 9.privileges; was public 覆写父类中的方法,便缩小了权限,错误

10.cannot inherit from final A

11.print() in B cannot override print() in A; overridden method is final

12.cannot assign a value to final variable INFO


java常见异常和错误