title: getter setter for Hashmap using generics
body: <p>I have the following two classes</p>
  
  <p>Animal Class</p>
  
  <pre><code>class Animal {
  
    Map&lt;String, A&gt; data = new HashMap &lt;String, A&gt;();
  
    public void setValue(HashMap&lt;String, ?&gt; val)
     {
       this.data = val;
     }
    public Map getValue()
     {
      return this.data;
     }
  }
  </code></pre>
  
  <p>Dog Class</p>
  
  <pre><code>class Dog extends Animal {
  
    public void index()
    { 
      Map&lt;String, A&gt; map = new HashMap&lt;String, A&gt;();
  
      map.put("name", "Tommy");
      map.put("favfood", "milk"); // want to pass Lists, Integers also
      setValue(map);
    }
  }
  </code></pre>
  
  <p>As you can see from the above code I am trying to set some values with keys in <code>index</code> method, but I am getting error warnings from eclipse in both two files. Error Messages are: </p>
  
  <p>In Dog Class File: </p>
  
  <pre><code>Multiple markers at this line
      - A cannot be resolved 
       to a type
      - A cannot be resolved 
       to a type
  </code></pre>
  
  <p>In Animal Class File :</p>
  
  <pre><code>Multiple markers at this line
      - A cannot be resolved to a type
      - A cannot be resolved to a type
      - Incorrect number of arguments for type Map&lt;K,V&gt;; it cannot be parameterized with arguments 
       &lt;HashMap&lt;String,A&gt;&gt;
  </code></pre>
  
  <p>The data type of the keys in HashMap will always be a String but the data types of values would be random, hence I am trying to use Generics. </p>
  
  <p>Coming from PHP background I still haven't been able to grasp the concept of Java Generics. Could you please tell me where is the mistake in my code?</p>