Class CityComparatorByMetersAboveSeaLevel

java.lang.Object
collection.comparators.CityComparatorByMetersAboveSeaLevel
All Implemented Interfaces:
Comparator<City>

public class CityComparatorByMetersAboveSeaLevel extends Object implements 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 Details

    • CityComparatorByMetersAboveSeaLevel

      public CityComparatorByMetersAboveSeaLevel()
  • Method Details

    • compare

      public int compare(City o1, City o2)
      Compares two City objects based on their elevation in meters above sea level.
      Specified by:
      compare in interface Comparator<City>
      Parameters:
      o1 - the first City object to be compared
      o2 - 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.