In this video, we will learn about working with compareTo(). The compareTo() which is present inside the comparable interface returns 3 types of value eg. A +ve, -ve or a zero. The compareTo() used by the sort() to sort any kind of object.
As we have seen already, The Integer class and String class already has overridden the compareTo() and given there implementation like all other wrapper classes. Now we have to build a compareTo() for our song class to make it eligible for sorting. We can sort the song objects based on various property like an artist, song title track or by the release year.
So let’s dive in and explore the compareTo() method of comparable interface and sort some customize objects. Do remember that it is one of the most important interview question that you need to prepare.
For more videos in the collection framework, consider subscribing by clicking the link below.https://www.youtube.com/channel/UCpUYkSDJpHug-vfC5S-NXRA?sub_confirmation=1
Stay tuned and like my Facebook page for more.https://www.facebook.com/seleniumexpress
You can write your unsolved query to email@example.com.
credits : -
Adventures by A Himitsu https://soundcloud.com/a-himitsu
Creative Commons — Attribution 3.0 Unported— CC BY 3.0 http://creativecommons.org/licenses/b...
Music released by Argofox https://youtu.be/8BXNwnxaVQE
Music provided by Audio Library https://youtu.be/MkNeIUgNPQ8
intro template :