This commit is contained in:
m-mun
2026-09-09 08:34:32 +09:00
parent 8e67b4ccb9
commit 1b863df929
181 changed files with 34869 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
/*
* PTra15_01.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra17_01 {
public static void main(String[] args) {
String str = null;
/*
* TODO このプログラムを実行するとNullPointerExceptionが発生します。
* 例外処理を行なって、例外処理が発生しました と表示されるようにプログラムを変更してください
*/
String[] list = str.split(",");
}
}

View File

@@ -0,0 +1,19 @@
/*
* PTra15_02.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra17_02 {
public static void main(String[] args) {
/*
* TODO
* commonパッケージのThrowExceptionUtilクラスから
* countDownメソッドを引数 10 で呼び出してください
*/
}
}

View File

@@ -0,0 +1,26 @@
/*
* PTra15_03.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra17_03 {
public static void main(String[] args) {
try {
/*
* TODO
* NumberFormatExceptionが発生 が表示されるように、
* 以下の処理を書き換えてください
*/
throw new ArrayIndexOutOfBoundsException();
} catch (NullPointerException e) {
System.out.println("NullPointerExceptionが発生");
} catch (NumberFormatException e) {
System.out.println("NumberFormatExceptionが発生");
} catch (Exception e) {
System.out.println("Exceptionが発生");
}
}
}

View File

@@ -0,0 +1,33 @@
/*
* PTra15_04.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra17_04 {
// 1文字ごとに遅らせる秒数(ミリ秒)
final static int SLEEP_TIME = 1000;
public static void main(String[] args) {
try {
numCheck(-10);
} catch (Exception e) {
System.out.println("例外が発生しました");
}
}
/* TODO 以下のメソッドのエラーを解決して、
* 実行時に 例外が発生しました と表示されるようにしてください。
*/
public static void numCheck(int num) {
if (num < 0) {
throw new Exception();
}
System.out.println(num + "正の範囲の数値です");
}
}

View File

@@ -0,0 +1,32 @@
/*
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
package common;
/**
* 例外を発生させるようなメソッドを集めたクラスです
* @author rhizome
*
*/
public class ThrowExceptionUtil {
// 1文字ごとに遅らせる秒数(ミリ秒)
final static int SLEEP_TIME = 1000;
/**
* 渡された引数からカウントダウンを実施する
* @param count
* @throws InterruptedException
*/
public static void countDown(int count) throws InterruptedException {
for(int i = count; i >= 0; i--) {
System.out.println(i);
Thread.sleep(SLEEP_TIME);
}
System.out.println("カウントダウンを終了します");
}
}