title: Java: problem with hashmap and keyset()
body: <p>Here's what I'm doing (it's my "homework"): the assignment is to make a map of gerbils and then flip through it using keySet() and get(key);</p>
  
  <pre><code>import java.util.*;
  
  class Gerbil
      {
      int gerbilNumber;
      Gerbil(int i)
          {
          gerbilNumber = i;
          }
      void hoop()
          {
          System.out.println("The gerbil can jump and its number is: " + gerbilNumber);
          }
      }
  
  public class GerbilMaze2
      {
      static Map&lt;String,Object&gt; fill(Map&lt;String,Object&gt; m)
          {
          m.put("Rat2", new Gerbil(2));
          m.put("Rat1", new Gerbil(1));
          m.put("Rat3", new Gerbil(3));
          return m;
          }
      public static void main(String[] args)
          {
          Map&lt;String,Object&gt; gerbils = fill(new HashMap&lt;String, Object&gt;());
          System.out.println(gerbils.keySet());
          for (String k : gerbils.keySet())
              {
              gerbils.get(k).hoop();
              }
          }
      }
  </code></pre>
  
  <p>Everything seems pretty fine all the way down to the moment when I call the hoop() method. gerbils.get(k) is an object (when I println it, it's shows up as an object) but for some reason "cannot find symbol".</p>
  
  <p>Thanks in advance for any help,
  Paul</p>