Hi,
I am confused on how the Comparator interface is used in Execise 5.2
public static Comparator integerComparator() {
return new Comparator() {
public int compare(Object o1, Object o2) {
int val1 = ((Integer)o1).intValue();
int val2 = ((Integer)o2).intValue();
return (val1<val2 ? -1 : (val1==val2 ? 0 : 1));
}
};
}
instead of
public class MyComparator implements Comparator {
public int compare(Object o1, Object o2) {
int val1 = ((Integer)o1).intValue();
int val2 = ((Integer)o2).intValue();
return (val1<val2 ? -1 : (val1==val2 ? 0 : 1));
}
}
Regards
KC
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/javaprogrammingwithpassion?hl=en