"Unexpected type required class found type parameter Attack"



这是我的代码(试图为我的类编写一个复制构造函数):

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有自己的默认构造函数。

您使用实际类名作为类型变量。这没有道理。也许你想要类似的东西

public class ArgumentTree extends DelegateTree<GameArgument, Attack>

相关内容

最新更新