Generics Exercises

  1. Generics Motivation
    1. Why would a developer want to use generics?
    2. Give 3 examples of when a developer should employ generics
    3. What's the difference between:
  2. Generics Basics
    1. Name a restriction when using a generic entity (and a work around)
  3. Comparable vs Comparator
    1. Talk with the other members of your table about what is the main difference between using the Comparable interface and the Comparator interface
    2. Expand the Vehicle class to allow objects of that type to be sorted by the call:
      Collections.sort( cars );
      in VehicleSorter class.
    3. Write the VehiclePriceComparator and VehicleYearPerPriceComparator classes so that the VehicleSorter class compiles and sorts as directed in the output statements.
  4. Last Modified: