Get 20% off all career paths from fullstack to AI
Live Online Classes in Design, Coding & AI — Small Classes, Free Retakes
Overview
AI, Data Science & Cloud Certificates from Google, IBM & Meta — 40% Off
One plan covers every Professional Certificate on Coursera. 40% off Coursera Plus Annual.
Unlock All Certificates
Explore the intricacies of Comparators in Java and learn how to avoid the "Comparison Method Violates Its General Contract!" exception in this 30-minute Devoxx conference talk by Stuart Marks. Dive deep into the Comparator interface, understanding its purpose and common pitfalls in implementation. Discover techniques for writing correct Comparators, including the use of utility methods introduced in Java 8 for composing complex Comparators from simpler ones. Gain insights from examples such as wrapper comparators, relational comparators, and logging comparators. Learn to differentiate between Comparator and Comparable interfaces while mastering the art of creating sophisticated and error-free Comparators for efficient sorting in Java applications.
Syllabus
Introduction
Title
Integers
Comparator
Illegal argument exception
Demo
Run
Writing a comparator
The problem
Wrapper comparator
Relational comparator example
Logging comparator example
Checking the results
Recap
Comparator vs Comparable
Taught by
Devoxx