NullPointerException with non-null <key,value> pair in hashtable : <p>I get a null pointer exception with a hashtable 'get' method call. The key is definitely not null. I checked at 'check1'(commented in the code) by prining the value of the variable item. I have valid list of strings. I still get a null pointer exception. What am I doing wrong ?     </p>

<pre><code>       List&lt;String&gt; l= new ArrayList&lt;String&gt;();
            //Values added to l;
            Hashtable&lt;String,int&gt; h=new Hashtable&lt;String,int&gt;();

            for(int i=0;i&lt;l.size();i++){
                String item= l.get(i);
                //check1
                int value= h.get(item); //exception arises at this point
                h.put(item,++value);
            }
</code></pre>
