如下Class
class A<T>{
public <T> String method1(T t){
return t.toString()+"-"+t.hashCode();
}
}
如下代码
A a = new A();
System.out.println(a.method1(1)); //1
System.out.println(a.method1("hi")); //2
A<String> str = new A<String>();
System.out.println(str.method1(1.1)); //3
答案选几?
A.编译谬误 //1
B.编译谬误 //1 和 //2
C.编译谬误 //1,//2, 和 //3
D.编译谬误 //3
E. 1-1
hi-<hashcode值>
1.1--<hashcode值>
F. 运行时抛出异样
发表回复