I have a HashMap. I am trying to retrieve the value and print it using the key from the user-code.
The code is:
lib.addbook(book2.getISBN(), book2);
Book ret = lib.getbook("978-81-291-1979-7");
System.out.println(ret);
Current Output:
O/P: LibraryPackage.Book@527c6768
I want the output to be a string and to display the actual value not the address of the book.
You have to implement (and override) the
toString()method in yourBookclass, and specify what you want the output to be. E.g.: