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
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?

Recommended Answers

you should pass an instance of type 'E'

Jump to Post

All 3 Replies

you should pass an instance of type 'E'

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.