/* interface Comparable { int compareTo( Object o ); // int compareTo( Comparable o ); } class A implements Comparable { int compareTo( Object o ); // "binary-method" } class B implements Comparable { int compareTo( Object o ); } ... new A().compareTo(new B()) ... interface Comparable<T> { int compareTo( T o ); } class A implements Comparable<A> { int compareTo( A a ); } class B implements Comparable<B> { int compareTo( B b ); } ... new A().compareTo(new B()) ... compilation error */ class G19 { // F-bounded polymorpism public static <E extends Comparable<E>> E max( E[] array ){ E m = array[0]; // throw exception when array is empty for( int i=1; i<array.length; ++i ){ if( m.compareTo(array[i]) < 0 ){ m = array[i]; } } return m; } public static void main( String[] args ){ System.out.println( max(args) ); System.out.println( max(new Integer[]{1,6,99,4,6}) ); } }