常用自定義異常拋出實現類

/* 非法參數 */
throw new IllegalArgumentException("name cannot be null");

/* 非法狀態 */
throw new IllegalStateException("this file is already locked and cannot be changed");

/* 不支持的操作 */
throw new UnsupportedOperationException("can't manpulate the file");


空指針異常: NullPointerException

類找不到: ClassNotFoundException

越界異常: IndexOutOfBoundsException

沒有訪問權限異常: IllegalAccessException



發佈了39 篇原創文章 · 獲贊 7 · 訪問量 10萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章