Why does Java Compiler raise “The local variable s may not have been initialized” in the finally block. I can not figure out in which flow of code, s remains un-initialized.
public static void test() {
String s;
try {
s = "abc";
} catch (Throwable e) {
s = "throwable";
} finally {
System.out.println(s.getClass()); //---->(The local variable s may not have been initialized)
}
}
If there is an OutOfMemory-Error in line 6, s cant be used in line 8.