Join Peggy Fisher for an in-depth discussion in this video Comparing objects with the comparable interface, part of Java Essential Training for Students.
- An important interface that's available…in the Java API is that Comparable Interface.…When we are working with classes and objects…we often want to compare a list of objects…possibly for sorting or to check to see…if two objects are the same.…The question is how to compare objects?…What defines a comparison of any two objects?…Or what defines the comparison of two address objects?…Maybe an address includes the house number,…the street name, the city, the state, and the zip code…or maybe something else.…
What value should we use?…Do we compare by street name by zip code?…That is where the Comparable Interface comes in handy.…By implementing the Comparable Interface…in our class we're required to provide a compareTo method…that returns either a positive number…if the calling object comes…before the other object, zero if the two objects are equal,…and a negative value if the first object comes…before the second object.…Again in order for this to work you must first have an idea…of what does it mean comes before or comes after.…
- Getting started with parsing
- Reviewing data types
- Using decisions
- Creating user-defined methods
- Command-line debugging
- Exploring the Java API
- Creating and instantiating classes
- Working with interfaces
- Storing items with arrays
Skill Level Intermediate
Q: How can I make my debugger function like the author’s?
1. Command Level Programming
2. Basics Review
4. Java API
5. Simulations and Algorithm Analysis
6. Classes and Objects
7. More on Classes
8. Data Structures
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.