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

前端 未结 6 1708
不思量自难忘°
不思量自难忘° 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条回答
  •  遥遥无期
    2020-11-29 00:51

    Yes, from Object class since your class extends Object implicitly. equals simply returns this == obj. hashCode implementation is native. Just a guess - it returns the pointer to the object.

提交回复
热议问题