Java HashMap "put" method in a for loop
<p>I am facing an issue while using <code>HashMap</code> in a for loop. Am I doing anything wrong? Is there any change I have to make? Below is the code and its output.</p>

<p><strong>Code:</strong></p>

<pre><code>public static void main(String[] args) {

    ArrayList&lt;Double&gt; arrBuckets = new ArrayList&lt;Double&gt;(3);

    HashMap&lt;Integer, ArrayList&lt;Double&gt;&gt; hashMap = new HashMap&lt;Integer, ArrayList&lt;Double&gt;&gt;();

    for(int i=1;i&lt;5;i++)
    {
        arrBuckets.clear();
        arrBuckets.add(0,(1.0*i)) ;
        arrBuckets.add(1,(2.0*i)) ;
        arrBuckets.add(2,(3.0*i)) ;

        hashMap.put(i, arrBuckets);
    }

    System.out.println("hashMap : "+hashMap);
}
</code></pre>

<p><strong>Below is Output :</strong></p>

<pre><code>hashMap : {1=[4.0, 8.0, 12.0], 2=[4.0, 8.0, 12.0], 3=[4.0, 8.0, 12.0], 4=[4.0, 8.0, 12.0]}
</code></pre>

<p><strong>But Output  should be like :</strong></p>

<pre><code>hashMap : {1=[1.0, 2.0, 3.0], 2=[2.0, 4.0, 6.0], 3=[3.0, 6.0, 9.0], 4=[4.0, 8.0, 12.0]}
</code></pre>
