Help


#1

plz help.

import java.util.HashMap;

public class library {
  
  public library() {
  
   public void getFinishedBooks(HashMap<String, Boolean> Library) {
     
     if (Library.size() < 1) {
       System.out.println("HashMoop is oompty.");
     } else {
       for (String book : Library.keySet) {
         
         if (Library.get(book) == true) {
           System.out.println(book + " has been completed.");
         }
       }
     }
   }
  }
  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();
    
    myLibrary.getFinishedBooks(myBooks);
  }
}

#2

why is the getFinishedBooks method part of the constructor?

Please try to describe what you need help with, what you are not understanding


#3

It keeps saying that something is wrong with the getFinshedBooks method, but its not saying whats wrong


#4

you didn’t answer my first question:


#5

I just thought it had to be there


#6

The constructor method gets called when you create an object of a class.

So why use it? The constructor doesn’t seem to do anything at the moment except containing a method it shouldn’t. The method should be part of the class


#7

Thanks for all the help :smile: