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 UA-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?
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
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.
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 ?
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
Yes please make a series of Java interview questions with answer.
Yes sir please add
Finally ,I understand the detail concept of Comparator & Comparable. thankyou so much sir.
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.
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.
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❤️
Durgesh bhai is GOAT❤️💖💕
Great learning
Yes sir we need a series of interviews for java
Best Ever video, easy explanation
No one gives this in depth insight in simple language, Thanks @LearnWithDurgesh
east or west Durgesh bhaiya is the best
I had been asked also this question, Make a video on 'serialization' also sir this is also very frequent asked question in interview
Sir u r incredible😊 Thanks for clearing my concepts
You explain difficult concepts in a very simple way
@Thank you Durgesh, it is an excellent explanation of Comparator and Comparable, please add steam of Comparator and if possible Comparable
Very helpful video 🙏🙏🙏🙏🙏❤️❤️❤️❤️❤️❤️❤️
Sir we want these type of example more Please do sir....
Confusion Cleared😇
Ha sir ji ese video chahiye
Thankyou so much! Very well explained. ✌
Thanks a lot for clearing this confusion
Amazing explanation
very helpful for interview point of view
Amazing❤❤❤❤❤❤
Thank you so much bhai
I had doubts regarding this one since long time
really helpful
Yes sir please make a interview series
Very nice...
So clearly explained
very nice explanation
yes sir makes the interview questions...
You are great Sir!!!!
great video. thanks .
Thank you so muchhh sir, for this informative concept.. I was too confused in between comparable and comparator and watching videos on UA-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?
Thank u ,it was easy to understand by your explanation.
Thanks Sir. Please provide more of such interview videos!
Good one.
Thanks sir😍
wow, so well explained , make videos in all imp topics sir pls
Sir, I have faced this topic in my last interview
Thanks bro😊
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
Sir plz continue this series
please make more such videos bhaiya thank you.👦🏻
Its very important for interview session please make some video on interview
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 the videos on Comparator and Comparable..
We can also say comparable use for default natural sorting order and comparator for custumomized
great make series on this
Thanku so much for video ,it really helpfull
Plz make video on java interview question
Thank you so much
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.
What is mean by current object and Emp Obj in this compare To method ,you can focus on this by taking example ...sir
Thank you sir
Thank you sir 😊
Please make a series of java interview questions
we need a series of interviews for java . please make a series
make videos on on concurrent multithreding like executor framework and java 11 features
Please make video on String vs String buffer vs String builder with example.
Thank you so much sir
Hi Durgesh
Thanks a lot for the valuable content you share,
Could you please make one video on concurrent hashmap + locking mechanism
Thank you
Yes Sir Please make some releted vdo
Great
Spring security par topic wise video bana sakte hai kya
Please make java interview questions series
Love diz vdeoo
Please also make video on hibernate,Spring Boot, microservices interview question and answers
Sir logical question kaisa puchha jaata hai ...uska v video upload kariyega naa aap
Sir Please make the series of interview questions
Continue sir
Sir please make video on hashcode and equals internal implementation
thanks sir
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.
Bhai ""serializable"" concept pe video bana do please... Asaan bhasha me.
THANK U SIR
Plz series of interview questions
If there is another list inside the emp object. Then how we will compare it.
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.
short short bolraheho bhaiiiii,,, kya yaar, its simple sort,,,i was confused kie wt shoort 🤔🤔,, but thank you bhai,,,
Bhaiya ,pls Java interview series for the experience
How to sort string in comparable and long in comparator?
Please make one more project on java using servlet and jsp
can you please make a series on kafka
Please explain compareTo and comparator with one more example.
one video for equals and hashcode also..
cobinely for equals hashcode and '==' operator
Sir how to fix this problem" communication link failure " in eclipse
Please make series
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 video on java project in intellij idea please bro
please make a video on singleton class
How can I connect with you?
Supb
Class main apna khuda ka custom sort karna hoga toh apko compareable ko implement karna padega .
Comparator with name sorting is not working
❤❤❤
Bhai interview video banóo