- Och vad är det här då?
- Jo det där, det är en dammsugare förstår fröken, tillåt mig demonstrera.
![]() |
hojt? | ritningar | hp48 | pascal | ||
|
One approach is to call Collections.sort again, this time specifying your own ordering. This ordering is done by defining a class "Comparer" that implements the java.util.Comparator interface, returning < 0, 0, or > 0 according to whether the first element is less than, equal to, or greater than the second. The difference between java.lang.Comparable and java.util.Comparator is simply that Comparable is used for types (such as Integer and String) that are built in to the core API, while Comparator is used in cases where you want to specify your own custom element ordering. Also, there are other features in collections worth investigating, such as the Map interface that replaces Dictionary and binary searches on ordered lists. The benefit of the collection framework is that it provides easier and more powerful use of Java language data structures.
|
||||||