Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Generics: Comparator type safety and unchecked conversion

807569Jun 26 2006 — edited Jul 7 2006
Hi,

I'm new to generics and I'm getting the following unchecked warning when using TableSorter in java 1.5

protected Comparator<Object> getComparator(int column) {
Class columnType = tableModel.getColumnClass(column);
Comparator comparator= columnComparators.get(columnType);
if (comparator!= null) {
return comparator; // warning here
}
if (Comparable.class.isAssignableFrom(columnType)) {
return COMPARABLE_COMAPRATOR;
}
return LEXICAL_COMPARATOR;
}

warning is : Type safety: The expression of type comparator needs unchecked conversion to conform to Comparator<Object>.

Any ideas on how to fix this?
Thanks for your help
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 4 2006
Added on Jun 26 2006
3 comments
413 views