为什么 Java 编译器会在 finally 块中引发“局部变量 s 可能尚未初始化”。我无法弄清楚s在哪个代码流中仍未初始化。
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)
}
}