I have found following code:
public class Ex7 {
static class Translator<T1, T2 extends String> {
T2 translate(T1 what) {
return what + " ";
}
}
public static void main(String[] args) {
System.out.println(
new Translator<Integer, String>().translate(1)
);
}
}
I don't understand why this code doesn't compile, since T2 is String and i want to return
String from the method "translate", compiler says that it expects T2 instead of String, but i understand that T2 is string as is is stated here:
new Translator<Integer, String>().translate(1)
Can someone please, explain this to me?