go to home page   go to next page

created: 6/26/2006


CHAPTER 53B — Comparable Interface

A class implements the Comparable interface when its objects can be arranged into a particular order. For example, the class String implements Comparable, because strings can be arranged into alphabetical order. Numeric classes (such as Integer or Double) implement Comparable since numbers can be arranged into numeric order.

Objects of a class that implements Comparable can be compared to each other to determine which comes first when the objects are arranged in order.

Chapter Topics:

This chapter describes Comparable for Java 5.0 and higher, which uses generics. Earlier versions of Java are somewhat different.


QUESTION 1:

Arrange these strings in order: "orange", "apple", "plum".