Map with custom value object
<p>I want to have a Map object to contain specific value types.</p>

<pre><code>Map&lt;String,Object&gt; foo = new HashMap&lt;String,Object&gt;();
foo.put("1",new Integer(1));
foo.put("2", new String("hello"):
for (Map.Entry&lt;Integer, Integer&gt; entry : foo.entrySet()) {
    if(entry.getValue() instanceof String) {
    //do something
    }
   else if(entry.getValue() instanceof Double) {
       //throw Exception
    }
}
</code></pre>

<p>You can see what i am trying to accomplish. I need specific Value types in my Map object so i don't have to put lots of if/else statements. How do i accomplish this ?</p>
