Hello All,


I have spent qite a bit of time trying to solve my problem, but it looks like I'm not getting even close.


Code:
public class MusicLibrary
{
   //instance variable declaration
   private Map<String, List<CD>> cdCatalogue;
   
   
   

   // constructor
   public MusicLibrary()
   {
      super();
      this.cdCatalogue = new TreeMap<String, List<CD>>();
   }
   
   //  instance methods
  public void displayCDs()
   {
      for (String eachKey : cdCatalogue.keySet())
      {
         
        cdCatalogue.get(eachKey);
        System.out.println(cdCatalogue.get(eachKey));//This doesn't work as it should
        
        

         
       
      }
   }
         

   public void populate()
   {
      List<CD> temp;
      temp = new ArrayList<CD>();
      temp.add(new CD("Andy Sheppard","Soft on the Inside", "Jazz",1990));
      this.cdCatalogue.put("Andy Sheppard", temp);
      temp = new ArrayList<CD>();
      temp.add(new CD("Barbara Thompson","Songs from the Centre of the Earth","jazz",1991));
      this.cdCatalogue.put("Barbara Thompson", temp);
}
}
The other class is:

Code:
public class CD
{
   /* instance variables */
   private String artist;  // name of artist or composer
   private String title;   // title of album
   private String genre;   // genre of album
   private int year;       // year of album release or composition
  

   /**
    * Constructor for objects of class CD
    */
   public CD(String anArtist, String aTitle, String aGenre, int aYear)
   {
      super();
      this.artist = anArtist;
      this.title = aTitle;
      this.genre = aGenre;
      this.year = aYear;
   }
   
   /* instance methods */

   /**
    * Returns the receiver's artist
    */
   public String getArtist()
   {
      return this.artist;
      
   }
  
   
   /**
    * Returns the receiver's title
    */   
   public String getTitle()
   {
      return this.title;
   }
   
   
   /**
    * Returns the receiver's genre
    */   
   public String getGenre()
   {
      return this.genre;
   }
   
   
   /**
    * Returns the receiver's year
    */
   public int getYear()
   {
      return this.year;
   }
   
   
   
  public void printString()
   {
     System.out.println(getArtist() + ", " + getTitle() + ", " + getGenre() + ", " + getYear());
   }
   
 }

My problem is with method dispayCDs() I just can't get it to work. I assume that I have written variable declaration and constructor in class MusicLibrary correct. It should be zero-argument constructor which assigns to cdCatalogue an empty instance of a suitable concrete class.
I think I should also use method printString() from class CD but when I try to do this i get compilation error non-static method cannot be refferenced from a static context.

Please push me in the right direction.
Regards