標籤:java 異常 錯誤
異常
1.NumberFormatException 數字格式化異常
2.ArithmeticException 算術異常
3.ArrayIndexOutOfBoundsException 數組超出綁定異常:沒有輸入參數,或輸入的參數不夠
4.NullPointerException null 指標異常:使用了未執行個體化的對象
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常見異常和錯誤