import java.io.FileReader;
import java.io.IOException;
public class ExceptionTypeExample {
// 検査例外: throws または try-catch が必須
public void read() throws IOException {
FileReader fr = new FileReader("test.txt"); // FileNotFoundException
}
// 非検査例外: throws や try-catch なしでもコンパイル可能
public void divide() {
int result = 10 / 0; // ArithmeticException
}
}