Implementing the equals method in java

前端 未结 7 1053
醉酒成梦
醉酒成梦 2021-01-18 15:39

This is my implementation of the equals class for a Coor class which is just contains 2 ints x and y. would this be the proper way of implementing this method?



        
7条回答
  •  甜味超标
    2021-01-18 16:05

    There's only one source to read for how to override equals and hashCode: chapter 3 of Joshua Bloch's "Effective Java".

    If you have a good IDE, like IntelliJ, it'll generate equals and hashCode the right way for you.

提交回复
热议问题