上級 › unreported exception must be caught の原因と直し方 › パターン1
unreported exception must be caught の原因と直し方
検査例外と非検査例外の境界。
1 import java.io.IOException; 2 3 public class Main { 4 public static void main(String[] args)____________________ { ^ 5 throw new IOException("boom"); 6 } 7 }
Main.java:5: error: unreported exception IOException;
must be caught or declared to be thrown
空欄を埋めてビルドを通す
検査例外はtry-catchで捕まえるか、throwsで宣言する必要があります。throwは動作、throwsは宣言です。
次の問題