Most appropriate answer when to use Comparable and when to use Comparator is : If object class (on which you want to do sorting ex : Emp.java is this video) is in your control, then you can use Comparable. If object class is not in your control, means you are using some 3rd party API to get data, or you are some library, it means you cant modify code of that object class, the you can use Comparator interface.
Thank you sir may God make your channel of 1 million subscribers because youtube tutors like you tech us that things that we can never learn by paying Thanks again❤️
Thank you so muchhh sir, for this informative concept.. I was too confused in between comparable and comparator and watching videos on TH-cam makes more confusion in my mind.. Like where to implement comparable when to call, how to print by using StringTo, exact difference between comparable n comparator.. Now I am clear with everything like from basic.. Bus mujhe voh (o1.marks - o2.marks); kaise run hota samjha naii I mean kaise compare hota kon chota kon bada n running process samjhi nai.. Baki sab clear
When - value is returned then it means the object 2 is greater than the object 1 and when + value is returned then it means the object 1 is greater than object 2, there is nothing more than that in it.
It's common sense, I mean if you subtract two values and you get negative results then it is obvious that the value one was smaller otherwise why would you have gotten a negative value as the result?
By using Java 8 all you want is to have lamba functions for overriding the functions of this comparable and comparator function interface. Else there is no difference. Lamba functions are pretty easy to understand.
hello bro what should i learn for java gui for android , do we have to design like html and css through code ? i have seen video where they just have select the view like button etc.
I tried in the interview, the interviewer gave me conceptuals questions and i was not selected... Thank you Durgesh Bhaijaan for providing such types of videos
Can we compare multiple fields in one call, something like collection.sort(emps , new IdCompare , new name Compare) Is there any alternative way to compare multiple fields in one call?
There's no point in comparing multiple fields, just think about that, at any given time you'll have to use one field only if you want to sort. For example how can you sort something by both name and id? Either you'd want that to be sorted by name or by id.
Bro can you tell me how we use this methods in quiz. Means if i want to prepare a mcq type quiz how should we apply these methods to compare options to answer and this is how we get marks as well.. so can you please make video on this please ?
Yes please make a series of Java interview questions with answer.
Yes sir please add
Sir, bhut sare videos dkehle iske, pr apne jo explain kia hai, vaisa clear duniya mai koi ni kr sakta...hath jod kr thanks apko
Finally ,I understand the detail concept of Comparator & Comparable. thankyou so much sir.
mast laga sir apka teaching style aur samjhane ka tarika thank You Sir
yes yes, Yes please make a series of Java interview questions with answer.
Most wanted channel learnWithDurgesh in social media.
Yes sir we need a series of interviews for java
Great learning
Most appropriate answer when to use Comparable and when to use Comparator is :
If object class (on which you want to do sorting ex : Emp.java is this video) is in your control, then you can use Comparable.
If object class is not in your control, means you are using some 3rd party API to get data, or you are some library, it means you cant modify code of that object class, the you can use Comparator interface.
You explain difficult concepts in a very simple way
Thanks a lot for clearing this confusion
Best Ever video, easy explanation
No one gives this in depth insight in simple language, Thanks @LearnWithDurgesh
very helpful for interview point of view
Sir we want these type of example more Please do sir....
@Thank you Durgesh, it is an excellent explanation of Comparator and Comparable, please add steam of Comparator and if possible Comparable
Thank u ,it was easy to understand by your explanation.
yes sir makes the interview questions...
Sir u r incredible😊 Thanks for clearing my concepts
So clearly explained
I had been asked also this question, Make a video on 'serialization' also sir this is also very frequent asked question in interview
great video. thanks .
Sir plz continue this series
Yes sir please make a interview series
Amazing explanation
Ha sir ji ese video chahiye
Thank you sir may God make your channel of 1 million subscribers because youtube tutors like you tech us that things that we can never learn by paying Thanks again❤️
Confusion Cleared😇
Durgesh bhai is GOAT❤️💖💕
very nice explanation
Thank you so much bhai
I had doubts regarding this one since long time
really helpful
wow, so well explained , make videos in all imp topics sir pls
You are great Sir!!!!
Thanks Sir. Please provide more of such interview videos!
Thankyou so much! Very well explained. ✌
great make series on this
Its very important for interview session please make some video on interview
Very helpful video 🙏🙏🙏🙏🙏❤️❤️❤️❤️❤️❤️❤️
Please make the videos on Comparator and Comparable..
east or west Durgesh bhaiya is the best
Very nice...
Thanks a lot sir.. Nicely explained.... Please make a playlist of java interview questions.
Sirji plz make video on how treemap works internally. Java
Please make a series of java interview questions
Yes Sir Please make some releted vdo
make videos on on concurrent multithreding like executor framework and java 11 features
Sir, I have faced this topic in my last interview
Thank you so much sir
Please make video on String vs String buffer vs String builder with example.
Thanku so much for video ,it really helpfull
Plz make video on java interview question
We can also say comparable use for default natural sorting order and comparator for custumomized
please make more such videos bhaiya thank you.👦🏻
Hi Durgesh
Thanks a lot for the valuable content you share,
Could you please make one video on concurrent hashmap + locking mechanism
Thank you so much
Spring security par topic wise video bana sakte hai kya
Thank you so muchhh sir, for this informative concept.. I was too confused in between comparable and comparator and watching videos on TH-cam makes more confusion in my mind.. Like where to implement comparable when to call, how to print by using StringTo, exact difference between comparable n comparator.. Now I am clear with everything like from basic.. Bus mujhe voh (o1.marks - o2.marks); kaise run hota samjha naii I mean kaise compare hota kon chota kon bada n running process samjhi nai.. Baki sab clear
When - value is returned then it means the object 2 is greater than the object 1 and when + value is returned then it means the object 1 is greater than object 2, there is nothing more than that in it.
It's common sense, I mean if you subtract two values and you get negative results then it is obvious that the value one was smaller otherwise why would you have gotten a negative value as the result?
Please make java interview questions series
Amazing❤❤❤❤❤❤
Thanks bro😊
Good one.
What is mean by current object and Emp Obj in this compare To method ,you can focus on this by taking example ...sir
we need a series of interviews for java . please make a series
Sir can you please make this video using java 8... most of the interviewers ask this nowadays how to use comparator, comparable using java 8
By using Java 8 all you want is to have lamba functions for overriding the functions of this comparable and comparator function interface.
Else there is no difference.
Lamba functions are pretty easy to understand.
Thank you sir
Please also make video on hibernate,Spring Boot, microservices interview question and answers
Thanks sir😍
Sir please make video on hashcode and equals internal implementation
Sir Please make the series of interview questions
hello bro what should i learn for java gui for android , do we have to design like html and css through code ? i have seen video where they just have select the view like button etc.
Thank you sir 😊
Plz series of interview questions
Thank you
Sir logical question kaisa puchha jaata hai ...uska v video upload kariyega naa aap
Great
Bhai ""serializable"" concept pe video bana do please... Asaan bhasha me.
Please make one more project on java using servlet and jsp
Sir how to fix this problem" communication link failure " in eclipse
Please make series
can you please make a series on kafka
Bhaiya ,pls Java interview series for the experience
If there is another list inside the emp object. Then how we will compare it.
one video for equals and hashcode also..
cobinely for equals hashcode and '==' operator
Have seen many comparable and comparator videos. M sure this is best. But u could have included the reverse sorting or multiple sorting ways also.
How to sort string in comparable and long in comparator?
thanks sir
Please explain compareTo and comparator with one more example.
THANK U SIR
I tried in the interview, the interviewer gave me conceptuals questions and i was not selected...
Thank you Durgesh Bhaijaan for providing such types of videos
Abhi kya kare ho
How can I connect with you?
Please make video on java project in intellij idea please bro
Love diz vdeoo
Continue sir
Can we compare multiple fields in one call, something like collection.sort(emps , new IdCompare , new name Compare)
Is there any alternative way to compare multiple fields in one call?
There's no point in comparing multiple fields, just think about that, at any given time you'll have to use one field only if you want to sort. For example how can you sort something by both name and id?
Either you'd want that to be sorted by name or by id.
Bro can you tell me how we use this methods in quiz. Means if i want to prepare a mcq type quiz how should we apply these methods to compare options to answer and this is how we get marks as well.. so can you please make video on this please ?
please make a video on singleton class
short short bolraheho bhaiiiii,,, kya yaar, its simple sort,,,i was confused kie wt shoort 🤔🤔,, but thank you bhai,,,
Supb
Comparator with name sorting is not working
Bhai interview video banóo
Class main apna khuda ka custom sort karna hoga toh apko compareable ko implement karna padega .
❤❤❤