posted 13 years ago
Output is:
first
second
How does this "get" method behave ? As both m1 and M2 have same values and I have not overridden hashcode(), will Object class's equals() method be called ?
I think the behaviour is like this:
1. There is no hashcode method so there is no way for the JVM to see if objects m1 and m2 contain different values
2. There is no equals method overridden so Object class's equals() is invoked and as both objects are different the code above works fine without m2 replacing m1's value.