Java - 克隆对象?

时间:2014-04-05 00:54:23

标签: java

您好我正在尝试克隆我的树的根节点,但它无法正常工作。

我有一个Node类:public class Node实现Cloneable

在其中我有

public Object clone(){

        try {
            return super.clone();
        }
        catch (CloneNotSupportedException e) {
            // This should never happen
            throw new InternalError(e.toString());
        }
    }

然后从那个课程的外面我试图做到这一点

root = new Node(board, player, 1, null);
fullTree = (Node)root.clone();
root = new Node(fullTree.getBoard(), player, 1, null);

但它不让我。任何人都有任何关于我哪里出错的想法?

0 个答案:

没有答案
相关问题