Package collection.comparators
Class CityComparatorByMetersAboveSeaLevel
java.lang.Object
collection.comparators.CityComparatorByMetersAboveSeaLevel
- All Implemented Interfaces:
Comparator<City>
This class provides a comparator for the City class that compares two cities
based on their elevation in meters above sea level.
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Constructor Details
-
CityComparatorByMetersAboveSeaLevel
public CityComparatorByMetersAboveSeaLevel()
-
-
Method Details
-
compare
Compares two City objects based on their elevation in meters above sea level.- Specified by:
compare
in interfaceComparator<City>
- Parameters:
o1
- the first City object to be comparedo2
- the second City object to be compared- Returns:
- a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
-