Skip to content

Instantly share code, notes, and snippets.

@sujeet100
Last active February 15, 2017 08:47
Show Gist options
  • Save sujeet100/6476dc6184e9c7bbf1c8edde9baf3db5 to your computer and use it in GitHub Desktop.
Save sujeet100/6476dc6184e9c7bbf1c8edde9baf3db5 to your computer and use it in GitHub Desktop.
Collections in Scala, Groovy and Java 8
public class Book {
private String name;
private String author;
private int numberOfPages;
public Book(String name, String author, int numberOfPages) {
this.name = name;
this.author = author;
this.numberOfPages = numberOfPages;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public int getNumberOfPages() {
return numberOfPages;
}
public void setNumberOfPages(int numberOfPages) {
this.numberOfPages = numberOfPages;
}
@Override
public boolean equals(Object o) {
return name.equals(((Book) o).name);
}
@Override
public int hashCode() {
return name.hashCode();
}
@Override
public String toString() {
return this.name + " : " + this.author + " : " + this.numberOfPages;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment