How default .equals and .hashCode will work for my classes?

前端 未结 6 1712
不思量自难忘°
不思量自难忘° 2020-11-28 23:54

Say I have my own class

public class MyObj { /* ... */ }

It has some attributes and methods. It DOES NOT implement equals, DOES NOT impleme

6条回答
  •  Happy的楠姐
    2020-11-29 00:48

    IBM's developerworks says:

    Under this default implementation, two references are equal only if they refer to the exact same object. Similarly, the default implementation of hashCode() provided by Object is derived by mapping the memory address of the object to an integer value.

    However, to be sure of the exact implementation details for a particular vendor's Java version it's probably best to look as the source (if it's available)

提交回复
热议问题