Problem with List
<p>I am a java newbie, and having some issue with "java.util.List".Below is my code,where I'm trying to create a list of objects but the result I am getting is undesired.Can you please help me in solving the issue.</p>

<pre><code>import java.util.*;

class  testMap
{
    public static void main(String[] args) 
    {


        HashMap&lt;String,Object&gt; childRowMap = new HashMap&lt;String, Object&gt;(); 
        List &lt;Object&gt; actList= new ArrayList &lt;Object&gt; ();

        for (int x=0;x&lt;2 ;x++ ){

        if(x==0){

        childRowMap.put("startDate","startDate"+x);
        childRowMap.put("endDate","endDate"+x);
        childRowMap.put("encodedValue"," enc"+x);

        }
        else if (x==1){
        childRowMap.put("startDate","startDate"+x);
        childRowMap.put("endDate","endDate"+x);
        childRowMap.put("encodedValue"," enc"+x);
        }
        System.out.println("Adding object in the postition "+ x);
        actList.add(x,childRowMap);

        }
                System.out.println(actList);
    }
}
</code></pre>

<p>Result:</p>

<pre><code>Adding object in the postition 0
Adding object in the postition 1
[{encodedValue= enc1, startDate=startDate1, endDate=endDate1}, {encodedValue= en
c1, startDate=startDate1, endDate=endDate1}]
</code></pre>

<p>===============</p>

<p>Why I am not getting objects with different values.Kindly helping me out in figuring the problem with my code..</p>
