nFact

n!

NullPointerExceptionがスローされないstaticフィールドアクセス

こんなコードがあった時に、

コメントにある通りNullPointerExceptionがスローされずにhogeが表示されます。
普段メソッド呼び出ししてフィールドにアクセスする書き方しないので割りと衝撃的でした。

この動作はJava言語仕様に同じ例があります。

http://docs.oracle.com/javase/specs/jls/se8/html/jls-15.html#d5e24400

Even though the result of favorite() is null, a NullPointerException is not thrown. That "Mount " is printed demonstrates that the Primary expression is indeed fully evaluated at run time, despite the fact that only its type, not its value, is used to determine which field to access (because the field mountain is static).

だそうです(適当