Java class confusion
<p>I am quite new to programming in Java, but I have some experience in c/c++, I am noticing some unwanted behaviour in some of my code, and I am just wondering how to fix it.</p>

<p>This is what I have:</p>

<pre><code>List&lt;State&gt; list = new ArrayList&lt;State&gt;();
State cur = new State();
cur.x = 1;
cur.y = 1;
list.add(cur);
cur.x = 2;
cur.y = 3;
list.add(cur);
cur.x = 3;
cur.y = 4;
list.add(cur);
for (State i : list)
    System.out.println(i.x + " " + i.y);


class State
{
    public int x = 0;
    public int y = 0;
}
</code></pre>

<p>This gives me an output of:
3 4
3 4
3 4</p>

<p>Where as I want the output to be:
1 1
2 3
3 4</p>

<p>How do I fix this?
Thanks,
paintstripper</p>
