title: Java generics: Declare map value of generic type
body: <p>I am new to generics.</p>
  
  <p>Having a <code>Map</code> like </p>
  
  <pre><code>private static Map&lt;String, Object&gt; map;
  </code></pre>
  
  <p>and a method like</p>
  
  <pre><code>public &lt;T&gt; T getObject(final Class&lt;T&gt; myClass) {
      return (T)map.get(myClass);
  }
  </code></pre>
  
  <p>How to change the map declaration in order to not have to do the cast when returning from the method ?</p>