Basically repeating what @Turing85 mentioned, but the issue is in your Application.getMax()
. You do not want to do Vector<Comparable<T>>
, you want to do Vector<T>
and then have the type parameter T
be defined as <T extends Comparable<T>>
. Here is what your corrected method header should look like.
public static <T extends Comparable<T>> T getMax (Vector<T> v)
When you say Vector<Comparable<T>>
, you are saying that you want a Vector
of Comparable
. And I don't mean "Objects that implement Comparable", you are literally saying that the only acceptable types permitted into your Vector is the Comparable class - which invalidates any classes that implement Comparable.
Here is an example of what I am saying.
Vector<Comparable<Integer>> comparables = new Vector<>();
//error - Integer is not a Comparable, it only IMPLEMENTS Comparable
comparables.add(12345);
Vector<Comparable<String>> comparables = new Vector<>();
//error - String is not a Comparable, it only IMPLEMENTS Comparable
comparables.add("abc");
Vector<Comparable<String>> comparables = new Vector<>();
Comparable<String> c =
new Comparable<String>() {
public int compareTo(String s) {
return 0;
}
};
//OK - Comparable<String> is a Comparable, so it works
comparables.add(c);
That's why it is much easier to say <T extends Comparable<T>>
and then just say Vector<T>
. If we switch out the getMax()
method header with the one I/Turing85 gave you, then your Application class should work easier.