标签:ext nbsp 必须 int 一个 ati compare john ...
1 class ArrayAlg{ 2 public static <T> T getMiddle(T...a){ 3 return a[a.length/2]; 4 } 5 }
String middle=ArrayAlg.<String>getMiddle("John","Q.","Public");
String middle=ArrayAlg.getMiddle("John","Q.","Public");
1 class ArrayAlg{ 2 public static <T> T min(T[] a){ 3 if(a==null||a.length==0) return 0; 4 T smallest=a[0]; 5 for(int i=1;i<a.length;i++) 6 if(smallest.compareTo(a[i])>0) 7 smallest=a[i]; 8 return smallest; 9 } 10 }
public static <T extends Comparable> T min(T[] a)...
T extends Comparable & Serializable
标签:ext nbsp 必须 int 一个 ati compare john ...
原文地址:http://www.cnblogs.com/vincentme/p/7754874.html