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