import java.util.*;
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException {
// Your code here!
/*int a =0/0;
System.out.println("XXXXXXXX");*/
String str="simizu";//ここをヌルにすると例外が発生するが、非検査例外なので、トライしなくてもOK
int i = str.length();
System.out.println(str + "は" + i + "文字");
//throw new StackOverflowError("StackOverflowError"); メモリーのオーバーフローここはキャッチできない、、そもそもサーバー落ちてたらキャッチできないよね
throw new IOException("IOException"); //検査例外 tryが必要 ただメソッドの横でスローしてるので大丈夫、もしメソッドでスローしなければトライキャッチが必要です。
}
}
}
参考資料
https://freelance-jak.com/technology/java/1157/
More than 3 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme