Java Collections - Custom Sorting by Comparator Interface | Java Tutorial Part 1

Published: 30 June 2020
on channel: Coding Examples
595
10

In this video, we will provide custom sorting order for the Java's TreeSet. We do this by implementing the Comparator interface in an external class and handing over that to TreeSet. The video shows custom sorting of the Product class by Product ID in Descending Order using the Comparator Interface. Note, the TreeSet here is the Collection of Product instances.

00:00 Introduction
00:14 Comparator Interface
02:45 Compare Method
08:45 Demo - About Product Class
09:53 Demo - TreeSetNumer Class
10:43 Demo - Implement Comparator Interface
17:25 Demo - Create TreeSet with Comparator
21:27 Demo - See How Custom Sort Works


On this page of the site you can watch the video online Java Collections - Custom Sorting by Comparator Interface | Java Tutorial Part 1 with a duration of hours minute second in good quality, which was uploaded by the user Coding Examples 30 June 2020, share the link with friends and acquaintances, this video has already been watched 595 times on youtube and it was liked by 10 viewers. Enjoy your viewing!