Java: Why aren't NullPointerExceptions called NullReferenceExceptions?

后端 未结 5 2225
孤城傲影
孤城傲影 2020-11-30 07:45

Was this an oversight? Or is it to do with the JVM?

5条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-30 08:07

    I guess it has to do with the fact that the JVM is coded in C++. Apart from that, pointers and references are nearly similar. You could say that the reference mechanism in Java is implemented using C++ pointers and the name 'NullPointerException' allows that implementation detail to shine through.

提交回复
热议问题