Output is true?

Isn’t the output supposed to be the name of the books?

Right now the output is:

import java.util.HashMap;

class Library {
  public Library (){
    public void getFinishedBooks(HashMap<String, Boolean> library){
      if (library.size() < 1){
        System.out.println("Library is empty");
      } else{
        for (String book: library.keySet()) {
          if (library.get(book) == true) {

    public static void main(String[] args){

      HashMap<String, Boolean> myBooks = new 
HashMap<String, Boolean>();
      myBooks.put("Road Down The Funnel", true);
      myBooks.put("Rat: A Biology", false);
      myBooks.put("TimeIn", true);
      myBooks.put("3D Food Printing", false);
      Library myLibrary = new Library();


then you should println(book), now you are using book as key of hashmap to get value.

Thanks :slight_smile:

looping over a hashmap will give you the key (book) in your case, do you understand? Then you can use the key to get the associated value, if you want

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.