public static String doSomething() {
String name = "ABC";
try {
throw new IOException();
} finally {
return name;
}
}
O/p:ABC
However below code needs throws in the method signature. Is it because return statement is missing or any other reason?
public static String doSomething() throws IOException {
String name = "ABC";
try {
throw new IOException();
} finally {
System.out.println("hello");
}
}