62,621
社区成员
发帖
与我相关
我的任务
分享
public class Max <DataType extends Comparable < DataType > > {
public static DataType max(DataType a, DataType b) {
int cmp = a.compareTo(b);
if (cmp == -1) {
return b;
}
return a;
}
}
太好了,是我想寻找的答案;谢谢前辈
public class Max {
public static <T extends Comparable < T >> T max(T a, T b) {
int cmp = a.compareTo(b);
if (cmp == -1) {
return b;
}
return a;
}
}