AdSense

網頁

2018/2/25

Java Error與Exception的差別

Java 錯誤(Error)與例外(Exception)的區別如下。


Error

Error是非預期的錯誤,無法也不必try catch,通常是因為應用程式執行環境造成的錯誤,例如OutOfMemoryErrorStackOverflowError


Exception

Exception是可預期的錯誤,需要try catch,通常是因為應用程式本身的錯誤,例如NullPointerExceptionClassCastExceptionIndexOutOfBoundsExceptionIOException

沒有留言:

AdSense