第1个回答 2013-09-20
是的,即使我们不重写hashCode方法,hashCode方法依然会被调用。
关于你的问题,英文的维基百科是这么说的 “All the classes inherit a basic hash scheme from the fundamental base class java.lang.Object, but instead many override this to provide a hash function that better handles their specific data. Classes which provide their own implementation must override the object method public int hashCode(). ”
所以java 自己在每个class里面会调用 hashCode 函数,不是空方法,native表示是用其它非java语言写的,使用JNI。