|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbook.Book
public class Book
A simple immutable class that describes a book. A book has a title, authors, and a unique identifier.
Constructor Summary | |
---|---|
Book(String title,
String authors)
Create a book with a title and authors. |
Method Summary | |
---|---|
boolean |
equals(Object obj)
Compares two books for equality. |
String |
getAuthors()
Get the book authors. |
int |
getId()
Get the book identification number. |
String |
getTitle()
Get the book title. |
int |
hashCode()
Returns a hash code value for this object. |
String |
toString()
Converts this book to a string starting with the book title, followed by " by " , followed by the
authors. |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Book(String title, String authors)
IllegalArgumentException
- if title or authors is null.title
- The book title.authors
- The book authors.Method Detail |
---|
public String getTitle()
public String getAuthors()
public int getId()
public boolean equals(Object obj)
true
if and only if the argument is not
null
and both books have the same identification
number.
equals
in class Object
obj
- The object to compare with.
true
if the objects are the same;
false
otherwise.public String toString()
" by "
, followed by the
authors.
toString
in class Object
public int hashCode()
hashCode
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |