I am having ArrayList containing String[], If i add new string[] into list, it also modifed previously added string [] objects
<p>I am adding string[] into Arraylist, But when i try to retrieve value from it, something wrong happening. and previous values of arraylist getting updated with new entry(String[])
Expected Output :<br>
first , sec<br>
1, 2<br>
one, two</p>

<p>Current Output :<br>
one, two<br>
one, two 
one, two</p>

<p>below is the code.</p>

<pre><code>   ArrayList&lt;String[]&gt; list = new ArrayList&lt;String[]&gt;();
   String[] temp ={"First","Sec"};
   list.add(temp);
   temp[0] ="1";temp[1]="2";
   list.add(temp);
   temp[0] ="one";temp[1]="two";
   list.add(temp);

   printLog(list);
</code></pre>

<p>here is the print method</p>

<pre><code>   private void printLog(ArrayList&lt;String[]&gt; result) {
    for (int i = 0; i &lt; result.size(); i++) {
        Log.d(TAG,"I="+i);
        String[] temp = result.get(i);
        Log.d(TAG,temp[0]+","+temp[1]+"\n");
    }

}
</code></pre>

<p>Any suggessions.</p>
