このことを考慮:
public class TestClass {
private String a;
private String b;
public TestClass()
{
a = "initialized";
}
public void doSomething()
{
String c;
a.notify(); // This is fine
b.notify(); // This is fine - but will end in an exception
c.notify(); // "Local variable c may not have been initialised"
}
}
理解できません。"b" は初期化されませんが、コンパイル時エラーである "c" と同じ実行時エラーが発生します。ローカル変数とメンバーの違いはなぜですか?
編集:メンバーを非公開にすることは私の当初の意図であり、疑問はまだ残っています...