You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
int a = biggerOne(3,5);
//int 和 double,取交为Number
Number b = biggerOne(3,5.5);
System.out.println(b.getClass().getName());
//String和int 取交为Object
Object c = biggerOne("1",2);``
关于为什么b是Double类型的猜测。
这应该是多态,类如Number b = new Double();
而为什么将Number改为Double报错,应该是因为泛型T可能的值有两个int和double,做了类型限制,这样代码更加灵活,出错率低。
The text was updated successfully, but these errors were encountered:
关于为什么b是Double类型的猜测。
这应该是多态,类如Number b = new Double();
而为什么将Number改为Double报错,应该是因为泛型T可能的值有两个int和double,做了类型限制,这样代码更加灵活,出错率低。
The text was updated successfully, but these errors were encountered: