0
0

More than 3 years have passed since last update.

java error処理のまとめ

Last updated at Posted at 2020-04-20

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/
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0