Comparable and Comparator Implementation in Java with Example [Interview Question]

preview_player
Показать описание
In this video of Comparable and comparator implementation in java we are going to see the implementation of comparator and comparable

Udemy Course of Code Decode on Microservice k8s AWS CICD link:

Course Description Video :

- Comparable and Comparable in Java
- Difference between Comparator and Comparable
- Example of Comparator and Comparable
- Create getters and setters
- toString() method
- Creating List and adding values in List
- When to use Comparable and when to use Comparator
- compareTo() method
- How to use comparable
- How to use Comparator

#comparable #comparator #comprableandcomparator

comparable and comparator program in java. Complete step by step by guide to implement comparable as well as comparator in java

Why there is comparable and comparator in java

Comparable vs Comparator

-------------------------------------------------------------------------------------------------------------------------------------

Code Decode Playlists

-------------------------------------------------------------------------------------------------------------------------------------
Subscriber and Follow Code Decode

--------------------------------------------------------------------------------------------------------------------------------------
Рекомендации по теме
Комментарии
Автор

thanks mam this was same example i have for my technical coding round and i have succesfully cleared it along with explanation you have given. keep up the good work

vrushabhulle
Автор

Best channel to prepare for java interviews.

SaurabhKumar-fozp
Автор

I now binge watch your videos even while eating, thanks for such amazing content !

gyanprakash
Автор

Opened to learn this topic....and after completing the video i remember only ur voice...🥰

ashubtech
Автор

Every topic is explained very well.Thanks a lot

basavarajappamc
Автор

you are very good with your explanation with example

sagarmeena
Автор

detailed and clear explaination of concepts !!

AvinashKumar-pswl
Автор

since Comparator is a Functional Interface, we can use Comparator.compare(e1, e2) directly in the Collections.sort. Code will be like Collections.sort(employeeList, (e1, e2)->e1.getEmployeeName().compareTo(e2.getEmployeeName()))

coincidentIndia
Автор

beautifully explained, such a simple understanding of complex topics.

akash
Автор

Hi Mam, Why do we need to take two arguments Employee e1 and Employee e2 in compare method of Comparator

ravindrasiddavatam
Автор

Mam I wasn't able to answer in LTI interview his question was how can u sort based on empId and if is same sort based on empName using comparator

maankhurana
Автор

Thank you for making it easy to learn these concept.

zabhashdamha
Автор

Amazing video and nicely explained. Thank you.

rohitnain
Автор

One small suggestion. If you are using java8 or above version then you can optimize your code by lambda expression.

naveensingh
Автор

1:50 - can you please explain what is the exact value that is expected in this.id and o.id ?

GauravKumar-zgkw
Автор

nice explanation mam, I have a query I tried using by name and by address it is not working can u help with that?

rohitgade
Автор

Can use comparator without implementation of comparable interface?

vrushaliyadav
Автор

What you do with compare method of comparator interface can be achieved with changing logic of compareTo method of comparable interface.
Correct me if wrong?
Then what is benefit of using comparator interface over comparable interface?

shankardayal
Автор

can u please explain elaborately regarding with better examples, this looks like it went fast forward

sureshgarine
Автор

I want to know how comparison is done. If first object is greater than the second then the compareTo method returns positive else negative and 0 if both are same. How these come into play when we are implementing either comparable or comparator? How the sorting is done based on that

flight_of_phoenix