//注意:Number并没有实现Comparable private static <T extends Number & Comparable<? super T>> T max(T[] values) { if (values == null || values.length == 0) return null; T max = values[0]; for (int i = 1; i < values.length; i++) { if (max.compareTo(values[i]) < 0) max = values[i]; } return max; } public static void main(String[] args) { int minInteger = max(new Integer[]{1, 2, 3, 5}); double minDouble = max(new Double[]{1.2, 2.2, -1d, -2.3}); }