← Skill tree CS Skill Tree 0 CSCD210

Comparable, Composition, and Comparator: the Bridge into CSCD 211

Textbook: BJP Ch 9 (Comparable and Comparator)

Where you are: Week 0 review > Comparable, composition, and Comparator

This part of the review is three short lessons. Work them in order:

  1. Comparable and compareTo: the natural order, the sign contract, and multi-key comparisons.
  2. Composition: a class that has another class as a field, and delegating to the part.
  3. Comparator: a swappable alternate ordering, as a named class or a lambda.

These three lead straight into CSCD 211: comparators taken further, and composition taken further.


Resources

Canonical: BJP (Reges and Stepp) §8 (composition), §10.2 (Comparable), §13.1 (Comparator sorting); Liang 10e §10 (composition), §13 (Comparable). Section numbers are grounded from the published tables of contents; exact page numbers depend on the printing and are pending a faculty spot-check.

Show 3 more resources
  • Java SE 25 API: java.lang.Comparable and java.util.Comparator.
  • Practice: code.jdoner.me CSCD 210 composition and ordering exercises (coding practice and tracing).
  • Video (URL pending verification): composition versus inheritance in Java.