Comparator uses a Collator to determine the proper, case-insensitive lexicographical ordering of two strings.
import java.text.Collator;
import java.util.Comparator;
class IgnoreCaseComp implements Comparator<String> {
Collator col;
IgnoreCaseComp() {
col = Collator.getInstance();
col.setStrength(Collator.PRIMARY);
}
public int compare(String strA, String strB) {
return col.compare(strA, strB);
}
}
Related examples in the same category