中文字幕一区二区人妻电影,亚洲av无码一区二区乱子伦as ,亚洲精品无码永久在线观看,亚洲成aⅴ人片久青草影院按摩,亚洲黑人巨大videos

Java 實例 - 自定義異常

Java 實例 Java 實例

以下實例演示了通過繼承 Exception 來實現(xiàn)自定義異常:

TestInput.java 文件

class WrongInputException extends Exception { // 自定義的類 WrongInputException(String s) { super(s); } } class Input { void method() throws WrongInputException { throw new WrongInputException("Wrong input"); // 拋出自定義的類 } } class TestInput { public static void main(String[] args){ try { new Input().method(); } catch(WrongInputException wie) { System.out.println(wie.getMessage()); } } }

以上代碼運行輸出結果為:

Wrong input

Java 實例 Java 實例

其他擴展