0

I have two classes
A Dog class whose constructor does not accept arguments,
public class Dog<pet> extends Animal<pet>{} whose constructor does not accept any arguments
and
public class Animal<pet>{} whose constructor accepts one argument

public class Dog<pet> extends Animal<pet>{
    public Dog(){
    super(/*what should go here?*/);
        //Constructor accepts no arguments
    }
}


public class Animal<pet>{
    public Animal(E name){
        //Constructor accepts one argument
    }
}

I need to pass an E type argument to super() inside the constructor of the Dog<pet> class.
How can I do this without passing any arguments to the dog constructor?
Thanks

2
Contributors
3
Replies
9
Views
2 Years
Discussion Span
Last Post by stultuske
0

Turns out I didn't have to extend the Animal class. All that was needed was to implement the AnimalInterface<E>.

Edited by Pyler

0

since we didn't even know of that interface's existance, it would have been hard to spot. but why don't you have to extend the class anymore?
somehow, I assumed the above snippet was not the actual code, just some 'concept'. I assumed there would be at least something of code/variables in the Animal class, making it important to extend it.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.