Java: Why am I getting null in the output?
<pre><code>public class A{

   TreeMap&lt;String, Double&gt; sortedPairList;
   HashMap&lt;String, Double&gt; PairList = new HashMap&lt;String, Double&gt;();

   public static void main(String[] args) {

   A p = new A();

    p.PairList.put("a00", 0.3920948902348);
    p.PairList.put("a01", 0.4920948902348);
    p.PairList.put("a02", 0.3420948902348);
    p.PairList.put("a03", 0.5920948902348);
    p.PairList.put("a04", 0.6720948902348);
    p.PairList.put("a05", 0.3940948902348);
    p.PairList.put("a06", 0.3920948902348);
    p.PairList.put("a07", 0.9920948902348);
    p.PairList.put("a08", 0.6920948902348);
    p.PairList.put("a09", 0.7920948902348);
    p.PairList.put("a10", 0.8820948902348);
    p.PairList.put("a11", 0.1220948902348);
    p.PairList.put("a12", 0.1920948902348);
    p.PairList.put("a13", 0.4520948902348);
    p.PairList.put("a14", 0.3434948902348);
    p.PairList.put("a15", 0.5690948902348);
    p.PairList.put("a16", 0.5920948902348);
    p.PairList.put("a17", 0.8920948902348);
    p.PairList.put("a18", 0.920948902348);
    p.PairList.put("a19", 0.9820948902348);
    p.PairList.put("a20", 0.1920948902348);
    p.PairList.put("a21", 0.5920948902348);
    p.PairList.put("a22", 0.3920948902348);
    p.PairList.put("a23", 0.3920948902348);

    p.sortPairList(p.PairList) ;

    for(String s : p.sortedPairList.keySet() ){
         System.out.println("key:: value: " + s + "  ::"+p.sortedPairList.get(s));
    }

}//end of main


public void sortPairList(HashMap&lt;String, Double&gt; pairlist) {
    ValueComparator comp = new ValueComparator(pairlist);

    sortedPairList = new TreeMap&lt;String, Double&gt;(comp);

    sortedPairList.putAll(pairlist);


}// end of sortedPredicatePairList

class ValueComparator implements Comparator&lt;Object&gt; {

    Map&lt;String, Double&gt; temp;

    public ValueComparator(Map&lt;String, Double&gt; base) {
        this.temp = base;
    }

    public int compare(Object p1, Object p2) {

        if ((Double) temp.get(p1) &lt; (Double) temp.get(p2)) {
            return 1;
        } else if ((Double) temp.get(p1) == (Double) temp.get(p2)) {
            return 0;
        } else {
            return -1;
        }

    }
}// end of class ValueComparator
}//end of classA
</code></pre>

<p><em><strong></em>*The output I am getting is the following, why I am getting nulls in the values which are repeated :<em>*</em></strong></p>

<p>key:: value: a07 ::0.9920948902348</p>

<p>key:: value: a19 ::0.9820948902348</p>

<p>key:: value: a18 ::0.920948902348</p>

<p>key:: value: a17 ::0.8920948902348</p>

<p>key:: value: a10 ::0.8820948902348</p>

<p>key:: value: a09 ::0.7920948902348</p>

<p>key:: value: a08 ::0.6920948902348</p>

<p>key:: value: a04 ::0.6720948902348</p>

<p>key:: value: a03 ::0.5920948902348</p>

<p><strong>key:: value: a21 ::null</strong></p>

<p><strong>key:: value: a16 ::null</strong></p>

<p>key:: value: a15 ::0.5690948902348</p>

<p>key:: value: a01 ::0.4920948902348</p>

<p>key:: value: a13 ::0.4520948902348</p>

<p>key:: value: a05 ::0.3940948902348</p>

<p>key:: value: a06 ::0.3920948902348</p>

<p>key:: value: a23 ::0.3920948902348</p>

<p>key:: value: a22 ::0.3920948902348</p>

<p><strong>key:: value: a00 ::null</strong></p>

<p>key:: value: a14 ::0.3434948902348</p>

<p>key:: value: a02 ::0.3420948902348</p>

<p>key:: value: a12 ::0.1920948902348</p>

<p><strong>key:: value: a20 ::null</strong></p>

<p>key:: value: a11 ::0.1220948902348</p>
