Effective Java! Consider Implementing Comparable
4 min readJan 10, 2021
Today we come to the final chapter of this section about methods common to all objects. Unlike the rest of the methods talked about in this section this method is actually not a method on the class Object
. That being said this method does affect the default operations in various other classes thus it is important to understand. The method we are talking about today is compareTo
and it's related interface, Comparable
.
So what is the purpose of the Comparable
interface? It has a purpose in line with Object
's equals
however its purpose is to do order…