小编Ali*_*Ali的帖子

"意外类型需要类找到类型参数攻击"

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

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....
    }
}
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

unexpected type  
 required: class  
 found:   type parameter Attack  
Run Code Online (Sandbox Code Playgroud)

只是为了澄清:我不想让代码通用.我已经知道我将使用的类型只是GameArgument和Attack.此外,Attack有自己适当的默认构造函数.

java generics copy-constructor type-parameter

2
推荐指数
1
解决办法
2257
查看次数

标签 统计

copy-constructor ×1

generics ×1

java ×1

type-parameter ×1