Exception
參考資料:(https://blog.csdn.net/zhousenshan/article/details/52877919)
Error:這種異常產生於JVM本身,通常被設計成不要被catch。 Runtime Exception:這種異常往往與環境有關,無法在compile時被檢查,發生狀況廣泛,程序也不需要捕獲。 普通異常:常見的異常大多屬於此。
java 提供兩個主要的異常 runtime exception、checked exception。
checked 異常也就是經常遇到的IO異常、SQL異常,這種異常JAVA 編譯器強制要求我們對這些異常進行catch。
常見的rumtime exception:
NullPointerException:對Null調用方法 ArrayIndexOutOfBoundsException:int[] a=new int[3]; int b = a[3]; ClassCastException:Object obj = new Object(); String s = (String)obj;
Last updated