Worked example
public static <T extends Comparable<T>> T max(T[] arr) {
T best = arr[0];
for (int i = 1; i < arr.length; i++) {
if (arr[i].compareTo(best) > 0) { // allowed thanks to the bound
best = arr[i];
}
}
return best;
}
compareTo returns a negative number if the value is smaller, 0 if equal, and a positive number if larger. Note the keyword is extends even for an interface bound.