【发布时间】:2013-10-13 12:18:21
【问题描述】:
我想为一个通用定义的类编写一个复制构造函数。我有一个内部类 Node,我将用它作为二叉树的节点。当我传入一个新对象时
public class treeDB <T extends Object> {
//methods and such
public T patient;
patient = new T(patient2); //this line throwing an error
//where patient2 is of type <T>
}
我只是不知道如何定义一个复制构造函数。
【问题讨论】:
标签: java generics copy-constructor