title: HashMap <String ,Class>
body: <p>I have an HashMap and i would like to print all the key values and the attributes of the classes.
  My class is:</p>
  
  <pre><code>class Country {
      String country;
      int population;
  
  Country(String  country, int population) {
      this.country=country;
      this.population=population;
    }
  }
  </code></pre>
  
  <p>I want to create hashMap where Integer will the year for example from 2010 to 2014, and the class country will be all the countries and population for that year, and later print that HashMap, by year and retreiving the country name and population.</p>
  
  <pre><code>int year=1960;
  HashMap&lt;Integer,Country&gt; country =new HashMap&lt;Integer, Country&gt;();
  for (int j=0; j&lt;10; j++)                                        
  {
      String country=countrylist[j]);    
      int population=populationlist[j]);     
      Country P=new Country(country,population);      
      country.put(year, P);         
  
      year++;
  
  }
  
  for (Map.Entry p : country.entrySet()) {
      Country country=(Country)p.getValue();
      year=(Integer)p.getKey();
      nameCountry=country.country;
      population=country.population;
      println(year,namecountry,population);
  }
  </code></pre>