java初学者一枚,学习别人的代码遇到类似如下的泛型方法定义:
public static <T> boolean check(String a, int b, String c) {
T t = null;
t = (T)fun(a,b,c);
return t != null;
}
调用的时候直接通过类名来调用,即 boolean f = a.check(a,b,c);
求问函数里的T是如何确定的?
...全文
2394打赏收藏
java泛型方法的一个小问题
java初学者一枚,学习别人的代码遇到类似如下的泛型方法定义: public static boolean check(String a, int b, String c) { T t = null; t = (T)fun(a,b,c); return t != null; } 调用的时候直接通过类名来调用,即 boolean f = a.check(a,b,c); 求问函数里的T是如何确定的?