【发布时间】:2012-07-23 13:05:41
【问题描述】:
这是我的代码(尝试为我的类编写一个复制构造函数):
public class ArgumentTree<GameArgument, Attack> extends DelegateTree<GameArgument, Attack>
{
public ArgumentTree()
{super();}
public ArgumentTree(ArgumentTree<GameArgument, Attack> sourceTree)
{
super();
Attack atck = new Attack(); // I get the Error here
more code....
}
}
我收到此错误:
unexpected type
required: class
found: type parameter Attack
只是为了澄清:我不想使代码通用。我已经知道我将使用的类型只有 GameArgument 和 Attack。此外,Attack 有自己的适当默认构造函数。
【问题讨论】:
-
你的代码是通用的,不管你想不想。
标签: java generics copy-constructor type-parameter