Java obj cloning problem
<p>I would need some help with the following code if you are kind.
Basically i have a tree node that remembers it's parent node, depth-level and his current state(a 2D array). 
Most variable names are written in my native language, i hope this is not a problem :</p>

<pre><code>public class Nod implements Cloneable {

private Nod parinte;//parent node
private int[][] stare;//state
private int cost;//depth-level
private String actiune;//the action used to obtain this node
private volatile int hashCode = 0;

public boolean equals(Object obj)
{
    if(this == obj)
    {
        return true;
    }
    if (!(obj instanceof Nod))
    {
        return false;
    }
    Nod nod = (Nod)obj;
    return cost == nod.getCost() &amp;&amp; actiune.equals(nod.getActiune()) 
            &amp;&amp; stare.equals(nod.getStareNod());
}

public int hashCode()
{
    StringBuffer strBuff = new StringBuffer();
    try 
    {
        int n = Problema.Dimensiune();//returns the dimension of state matrix
        for (int i=0;i&lt;n;i++)
            for (int j=0;j&lt;n;j++)
                strBuff.append(stare[i][j]);
        strBuff.append(cost);
        strBuff.append(actiune);

        String str = strBuff.toString();
        hashCode = str.hashCode();

    } 
    catch (IOException e) {
        e.printStackTrace();
    }

    return hashCode;
}   

  public Object clone() throws CloneNotSupportedException 
  {
        return super.clone();
  }


public static boolean goUp(int[][] st) throws IOException
{

    int n = Problema.Dimensiune();
    boolean ok = false;
    int[][] a = st;

    for (int i=0;i&lt;n;i++)
        for (int j=0;j&lt;n;j++)
        {
            if (a[i][j] == 0)
                if (i != 0)
                    ok = true;
        }
    return ok;
}

public static boolean goDown(int[][] st) throws IOException
{

    int n = Problema.Dimensiune();
    boolean ok = false;
    int[][] a = st;

    for (int i=0;i&lt;n;i++)
        for (int j=0;j&lt;n;j++)
        {
            if (a[i][j] == 0)
                if (i != (n-1))
                    ok = true;
        }
    return ok;
}

public static boolean goLeft(int[][] st) throws IOException
{

    int n = Problema.Dimensiune();
    boolean ok = false;
    int[][] a = st;

    for (int i=0;i&lt;n;i++)
        for (int j=0;j&lt;n;j++)
        {
            if (a[i][j] == 0)
                if (j != 0)
                    ok = true;
        }
    return ok;
}

public static boolean goRight(int[][] st) throws IOException
{

    int n = Problema.Dimensiune();
    boolean ok = false;
    int[][] a = st;

    for (int i=0;i&lt;n;i++)
        for (int j=0;j&lt;n;j++)
        {
            if (a[i][j] == 0)
                if (j != (n-1))
                    ok = true;
        }
    return ok;
}


public static int[] Zero(int[][] st) throws IOException
{

    int[][] a = st;
    int n = Problema.Dimensiune();
    int[] b = new int[2];

    for (int i=0;i&lt;n;i++)
        for (int j=0;j&lt;n;j++)
            if (a[i][j] == 0)
            {
                b[0] = i;
                b[1] = j;
            }

    return b;
}

public static int[][] Actiune(int[][] st, String s) throws IOException
{

    int[][] a = st;
    int[] b = Zero(st);

    if ((goRight(st) == true) &amp;&amp; (s == "right"))
    {

        a[b[0]][b[1]] = a[b[0]][b[1]+1];
        a[b[0]][b[1]+1] = 0;
    }

    if ((goLeft(st) == true) &amp;&amp; (s == "left"))
    {

        a[b[0]][b[1]] = a[b[0]][b[1]-1];
        a[b[0]][b[1]-1] = 0;
    }

    if ((goUp(st) == true) &amp;&amp; (s == "up"))
    {

        a[b[0]][b[1]] = a[b[0]-1][b[1]];
        a[b[0]-1][b[1]] = 0;
    }

    if ((goDown(st) == true) &amp;&amp; (s == "down"))
    {

        a[b[0]][b[1]] = a[b[0]+1][b[1]];
        a[b[0]+1][b[1]] = 0;
    }

    return a;
}

public Nod(){}

public Nod (int[][] st) 
{
    parinte = null;
    stare = st;
    cost = 0;
    actiune = null;
}

public Nod (Nod nod)
{
    parinte = nod.parinte;
    stare = nod.stare;
    cost = nod.cost;
    actiune = nod.actiune;
}

public Nod(Nod nodp, String ac) throws IOException
{
    this.parinte = nodp;
    this.cost = parinte.getCost()+1;
    this.actiune = ac;
    this.stare = Actiune(parinte.getStareNod(),actiune);
}

public void setCost(int cost)
{
    this.cost = cost;
}

public int getCost(){
    return this.cost;
}

public void setStareNod(int[][] stare)
{
    this.stare = stare;
}

public int[][] getStareNod(){
    return this.stare;
}

public void setNodParinte(Nod parinte)
{
    this.parinte = parinte;
}

public Nod getNodParinte() throws IOException{
    return this.parinte;
}

public void setActiune(String actiune)
{
    this.actiune = actiune;
}

public String getActiune()
{
    return this.actiune;
}
</code></pre>

<p>}</p>

<p>Now, i create an initial node and after, a child-node from it. The problem is that when i create the child-node, the parent's 2D array becomes identical with the child's array. I tried to clone the node object but it didn't fix it. I would appreciate if someone has an ideea how to fix it and shares it. </p>

<pre><code>public class test {

public static void main(String[] args) throws IOException, CloneNotSupportedException
{   
    int[][] p = Problema.stareInitiala();
    Nod nod = new Nod(p);

    Nod nodc = (Nod) nod.clone();
    Nod nod1 = new Nod(nodc,"right");

    Nod nod1c = (Nod) nod1.clone();
    Nod nod2 = new Nod(nod1c,"up");

    if (nod.getStareNod().equals(nod.getStareNod()))
        System.out.print("ok");
    else 
        System.out.print("not ok");
}
</code></pre>

<p>}</p>

<p>So if p = {{7,2,4},{5,0,6},{8,3,1}} the if statement should return "not ok", but instead i get the "ok" message.</p>
