Created
February 24, 2012 21:19
-
-
Save mjedynak/1903807 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Book { | |
private String author; | |
private String title; | |
private int pages; | |
public Book(String author, String title, int pages) { | |
this.author = author; | |
this.title = title; | |
this.pages = pages; | |
} | |
@Override | |
public boolean equals(Object obj) { | |
if (obj == null) { | |
return false; | |
} | |
if (getClass() != obj.getClass()) { | |
return false; | |
} | |
final Book other = (Book) obj; | |
return Objects.equals(this.author, other.author) && Objects.equals(this.title, other.title) && Objects.equals(this.pages, other.pages); | |
} | |
@Override | |
public int hashCode() { | |
return Objects.hash(author, title, pages); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment