Matthew Brown wrote:By the way, I think the way to turn your runtime exception into a compile-time error is to declare it like this:
Because Integer implements Comparable<Integer>, and String implements Comparable<String>, option A will no longer compile because they can't be compared with each other. The problem with the example given is that's it's partly generic, but it hasn't gone all the way.