equals() method for classes with bidirectional association

前端 未结 4 1022
时光说笑
时光说笑 2021-01-17 22:06

I am trying to implement equals method for Java classes Book and Chapter in my application. Book has a set of Chapt

4条回答
  •  执念已碎
    2021-01-17 23:07

    A book should be equal to another book only if their ISBNs are equal. So implement the book equals only based on that field.

    For the chapter - compare the chapter number and the owning Book

提交回复
热议问题