public class StringComparator
extends java.lang.Object
implements java.util.Comparator
Comparator interface.
It is suitable for use on any objects for which the toString
method provides a suitable basis for object comparison.
You might think that calling java.text.Collator.getInstance
ought to provide much the same thing; however that gives you a
compare method which casts to String rather
than calling the toString method on its arguments,
leading to a ClassCastException in most useful cases.
I wonder why it does that?
| Constructor and Description |
|---|
StringComparator() |
| Modifier and Type | Method and Description |
|---|---|
int |
compare(java.lang.Object o1,
java.lang.Object o2) |
boolean |
equals(java.lang.Object obj) |
Copyright © 2017 Central Laboratory of the Research Councils. All Rights Reserved.