previous |
start |
next
Anonymous Classes
- Commonly used in factory methods:
public static Comparator
comparatorByName()
{
return new Comparator()
{
public int compare(Object o1, Object
o2) { . . . }
};
}
- Collections.sort(a,
Country.comparatorByName());
- Neat arrangement if multiple comparators make sense
(by name, by area, ...)
previous |
start |
next