我有一些代码如下:
public class java_generic {
public static void main(String[] args) {
T t = new X();
t.<Object>m(new Object());
t.<String>m(new String());
}
static class T {
<E> void m (E e){
System.out.println("here is T");
}
}
static class X extends T {
void m (String o){
System.out.println("here is X");
}
}
}
据我了解,类型擦除后,类T
将变为:
static class T {
void m (Object e){
System.out.println("here is T");
}
}
并且 m 过载。
拥有m(Object)
and m(String)
,我希望结果是
here is T
here is X
然而,结果是
here is T
here is T
我想知道为什么结果会是这样。