Search code examples
javagenericscopy-constructortype-parameter

"Unexpected type required class found type parameter Attack"


this is my code (trying to write a copy constructor for my class):

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....
    }
}

I am getting this error:

unexpected type  
 required: class  
 found:   type parameter Attack  

just to clarify: I don't want to make the code generic. I already know that the types I will use will be only GameArgument and Attack. Also, Attack has its own proper default constructor.


Solution

  • You are using actual class names as type variables. This doesn't make sense. Maybe you want something like

    public class ArgumentTree extends DelegateTree<GameArgument, Attack>