Implementation of generic interface with specific type in Java

Viewed 2469

Consider the following generic interface:

interface Petlover<T>{
    void train(T somePet);
}

I understand that it's possible to provide generic implementations to generic interfaces (e.g., class MalePetLover<T> implements Petlover<T>). But I am having trouble implementing the interface for a specific type only:

class Dogperson implements Petlover<T> {
    int age;

    void train(String someDog){...};
}

The compilation error is train(String) in Dogperson cannot implement train(T) in Petlover. What would be a right way to handle this?

2 Answers
Related