I have a situation requiring a generic Comparator type, for now this has been implemented using a raw Comparator type, but I would like to rewrite this to a genuine generic type, unfortunately without success yet. Basically what I would like to achieve is something like:
public class Test
{
public int myCompare( Comparator<? extends Object> cmp, Object e1, Object e2 )
{
return cmp.compare(e1,e2);
}
}
I have tried several versions of the unbounded wildcard, but they all seem to result in some kind of compiler error, the above attempt results in something like:
"The method compare(capture-of ? extends Object, ... is not applicable for the arguments (Object, Object )."
Question is how to write this down properly?
Regards,
Wieant