我有一条 class Dog 扩展动物
。
然后,我将大麻守则方法称为如下方法。
Animal animal = new Dog(200);
System.out.println(animal.hashCode());
Here,
If I ve overridden the hashCode() in the Dog class it will be returned.
Else if I ve overridden the hashCode() in the Dog class it will be returned.
Else some integer returned.
我想知道......
Why does it call the hashCode() of the super class when it is not overriden in the Dog class? How and what the some integer generated
When the hashCode is not generated in anywhere. (I have heard that it is the memory location of the object but not sure.)