Deep Copying Attempt
<p>I am trying to build a method to deep copy a class:</p>

<pre><code>public MyClass clne() {
    MyClass cpy = new MyClass();
    cpy.var1 = getVar1(); //getVar1 is a method returning the value of var1
    cpy.var2 = getVar2();
    return cpy;
}
</code></pre>

<p>However, when I run:</p>

<pre><code>MyClass x = new MyClass();
x.var1 = 18;
MyClass y = x.clne();
y.myMethod(); // Where myMethod is a method changing the value of var1 to, say 4.
System.out.println(x.var1);
</code></pre>

<p>The value of x.var1 is 4.</p>

<p>Am I doing something wrong?
Thank you :)</p>
