I try to create an abstract class with generics. The business logic is to translate a text from one language to another. There must be a Translator
class for each l
Just add it where you define your Generics :
public abstract class Translator <T extends OriginalText, V> {
public abstract <V extends LanguageTranslation> V translate(T originalText);
}
Btw, this is confusing because the V
definition is overriden in your method. Why not doing this :
public abstract class Translator <T extends OriginalText, V extends LanguageTranslation> {
public abstract V translate(T originalText);
}
EDIT: explaining why you have a warning on V
It's exactly the same as :
public abstract class Translator <T extends OriginalText, V> {
public abstract <K extends LanguageTranslation> K translate(T originalText);
}
Now inside the method you have 3 generics :