Data Structures in Java: Part 8, The Comparable Interface, Part 2

Baldwin shows you why the elements stored in a TreeSet collection need to be references to objects instantiated from a class that implements the Comparable interface, and briefly discusses an alternative approach using the Comparator interface.

provided by: 
Originally published at Internet.com


Java Programming, Lecture Notes #1364 * Preface * Preview * Discussion and Sample Programs * Summary * What's Next ----------------------------------

Preface

This is the eighth lesson in a miniseries on Java data structures and the Java Collections Framework. The first lesson in the miniseries was entitled Data Structures in Java: Part 1, Getting Started. The previous lesson was entitled Data Structures in Java: Part 7, The Comparable Interface, Part 1.

The purpose of this miniseries is to help you learn the essential features of Object-Oriented data structures in Java using the Collections Framework.

This is also the second and final lesson in a sub-series on the Comparable interface. The purpose of the lessons in the sub-series is to teach you about the interactions between the Comparable interface and the Collections Framework, particularly with respect to the Set, SortedSet, and SortedMap interfaces of the Collections Framework. This lesson discusses Set and SortedSet. A discussion of SortedMap will be deferred for inclusion in a subsequent lesson.

Viewing tip

You may find it useful to open another copy of this lesson in a separate browser window. That will make it easier for you to scroll back and forth among the different listings while you are reading about them...

Read article at Internet.com site
Regional Articles
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 Alabama
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 Alaska
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 Arizona
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 Arkansas
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 California
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 Colorado
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 Connecticut
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 DC
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 Delaware
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 Florida
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 Georgia
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 Hawaii
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 Idaho
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 Illinois
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 Indiana
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 Iowa
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 Kansas
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 Kentucky
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 Louisiana
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 Maine
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 Maryland
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 Massachusetts
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 Michigan
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 Minnesota
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 Mississippi
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 Missouri
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 Montana
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 Nebraska
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 Nevada
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 New Hampshire
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 New Jersey
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 New Mexico
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 New York
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 North Carolina
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 North Dakota
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 Ohio
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 Oklahoma
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 Oregon
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 Pennsylvania
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 Rhode Island
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 South Carolina
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 South Dakota
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 Tennessee
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 Texas
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 Utah
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 Vermont
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 Virginia
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 Washington
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 West Virginia
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 Wisconsin
- Data Structures in Java: Part 8, The Comparable Interface, Part 2 Wyoming

Rss   Delicious   Digg   Add To My Yahoo   Add To My Google   Bookmark   Search Plugin

Topics:
Architecture & Design Languages & Tools Project Management Web Services
Database Microsoft & .NET Security Wireless
Java Open Source Techniques XML