#멋쟁이사자처럼 #부트캠프 #백엔드 #JAVA
RuntimeException VS Exceptionpublic class Main {
public static void methodA() throws RuntimeException {
}
public static void methodB() throws Exception {
}
public static void main(String[] args) {
methodA();
methodB(); // Unhandled exception: java. lang. Exception
}
}
FileInputStream fis = null;
try {
fis = new FileInputStream("abc");
} catch (Exception e) {
System.out.println(e);
} finally {
try {
fis.close();
} catch (IOException e) {
System.out.println(e);
}
}
try (FileInputStream fis2 = new FileInputStream("abc")) {
// ...
} catch (Exception e) {
System.out.println(e);
}