Interview Question | Comparable vs Comparator Detailed Explanation with Example In Java | JavaTechie

  Рет қаралды 35,056

Java Techie

Java Techie

2 жыл бұрын

This tutorial You will learn What is Comparable & Comparator in Java
When to use Comparable
When to use Comparator
How to add multi compare logic using Comparator
#javatechie #InterviewQA #Java #Collection
GitHub:
github.com/Java-Techie-jt/
Blogs:
/ javatechie
Facebook:
/ 919464521471923
guys if you like this video please do subscribe now and press the bell icon to not miss any update from Java Techie
Disclaimer/Policy:
--------------------------------
Note : All uploaded content in this channel is mine and its not copied from any community ,
you are free to use source code from above mentioned GitHub account

Пікірлер: 36
@RaviShankar-xy6zh
@RaviShankar-xy6zh 2 жыл бұрын
Buddy you always bring the insights of strong concepts through your eloquent videos. Need of the hour
@Javatechie
@Javatechie 2 жыл бұрын
Thanks buddy
@vasanthraj3883
@vasanthraj3883 2 ай бұрын
Very helpful for me, thanks sir.
@josephthecreator
@josephthecreator Жыл бұрын
Extremely helpful, thank you for this tutorial!
@imBalji
@imBalji 2 жыл бұрын
Excellent explanation. Thankyou sir
@vengateshm2122
@vengateshm2122 2 жыл бұрын
Indeed very useful. Thank you.
@sivajames07
@sivajames07 2 жыл бұрын
This is the most interview question I have been asked for many times
@shyaammuthusamy7370
@shyaammuthusamy7370 Жыл бұрын
Awesome explanation.
@sujithasugumar543
@sujithasugumar543 Жыл бұрын
Awesome explanation thanks a lot
@crazycom7819
@crazycom7819 2 жыл бұрын
Good topic
@sathiskumarp
@sathiskumarp Жыл бұрын
Good one
@arhianalbis918
@arhianalbis918 Жыл бұрын
The T chart at 0:55 is gold!!
@fuadgafarov
@fuadgafarov 2 жыл бұрын
Thanks
@ashimroy3891
@ashimroy3891 8 ай бұрын
If ever encountered that two objects have the same ID, what if I straight away deny that it is not possible. Will it be wrong ?
@Javatechie
@Javatechie 8 ай бұрын
Of course it's wrong that's the point of equals and hashcode contract you need to customize it as per your usecase
@anugantigowtham
@anugantigowtham 2 жыл бұрын
Explanation is straight to the point but , it would have been better if you had explained the contract between hashcode and equals also.
@foodgallery5819
@foodgallery5819 Жыл бұрын
Thank you :)
@adityavyas6603
@adityavyas6603 2 жыл бұрын
Java Basant.. Very good video Please create video on Junit testing Mockito wiremock etc
@Javatechie
@Javatechie 2 жыл бұрын
Hi Aditya , mockito video is already there please check in my channel
@natureParadise777
@natureParadise777 2 жыл бұрын
Good one, please keep uploading video like this
@tanujkumaragrawal4756
@tanujkumaragrawal4756 2 жыл бұрын
@arhianalbis918
@arhianalbis918 Жыл бұрын
Question: could you make a generic comparator if instead of passing you pass it and then you could sort any type of object by name or id or whichever parameter you specify, not only Student-type objects?
@Javatechie
@Javatechie Жыл бұрын
I will definitely try that
@arhianalbis918
@arhianalbis918 Жыл бұрын
@@Javatechie Great. I would love to know if it works.
@RAJU9622
@RAJU9622 2 жыл бұрын
Thanks Basant is it any different way we can achieve using Java8 streams?
@Javatechie
@Javatechie 2 жыл бұрын
Yes buddy . Already i explained how to use functional interface with lambda please checkout my java 8 playlist
@jyotisstyle
@jyotisstyle 2 жыл бұрын
Sir, Can you please make one video on STATIC keyword? In interview they always ask about static keyword in JAVA. Thank you in advance.
@ShinAkuma
@ShinAkuma 2 жыл бұрын
Not a good idea to create a separate class for every different comparator. Better to use lambda expression in Collections.sort(); I also faced this question today in an interview. Suppose I have an Employee class like this, Employee has a EmployeeID, EmployeeName and Department. Now I have a Map like this. HashMap = new HashMap(); Sample data: hm.put( new Employee(1, "Basant", "DepA") , 0); hm.put( new Employee(2, "Rahul", "DepB") , 0); hm.put( new Employee(3, "Sunny", "DepA") , 0); Now using Stream, I need to get the result like this. [ DepA => [Basant, Sunny] , DepB => [ Rahul ] ] Basically we create a Department pojo with String name variable. And return the result in this format. ArrayList< ArrayList >. I wasn't able to do it at the moment in the interview, but later on I did it, If you could cover this questions in a video as well, it would be very helpful to a lot of people.
@Javatechie
@Javatechie 2 жыл бұрын
Thanks buddy this we can do using grouping method of stream
@pramitranjan4338
@pramitranjan4338 2 жыл бұрын
Bhai please make logical coding video using Java 8
@Javatechie
@Javatechie 2 жыл бұрын
Yes I will do than
@ktmurali3274
@ktmurali3274 2 жыл бұрын
Please upload ReactJs
@Javatechie
@Javatechie 2 жыл бұрын
Will start soon
@ktmurali3274
@ktmurali3274 2 жыл бұрын
Please upload ReactJs it is more helpful us
@kumaresanperumal2581
@kumaresanperumal2581 Жыл бұрын
Thanks
Interview Question | Comparable vs Comparator in Java
12:58
Telusko
Рет қаралды 641 М.
50 YouTubers Fight For $1,000,000
41:27
MrBeast
Рет қаралды 202 МЛН
Java 8 Streams | map () & flatMap() Example | JavaTechie
15:37
Java Techie
Рет қаралды 210 М.
I solved 950 coding questions. Here's what I learned.
5:27
Ashhad Ahmad
Рет қаралды 639 М.
Interfaces vs Abstract Classes
14:43
Raw Coding
Рет қаралды 14 М.
Differences between Comparable and Comparator
5:49
Durga Software Solutions
Рет қаралды 316 М.
iPhone 15 Pro Max vs IPhone Xs Max  troll face speed test
0:33
Опасность фирменной зарядки Apple
0:57
SuperCrastan
Рет қаралды 9 МЛН
1$ vs 500$ ВИРТУАЛЬНАЯ РЕАЛЬНОСТЬ !
23:20
GoldenBurst
Рет қаралды 1,9 МЛН
Как бесплатно замутить iphone 15 pro max
0:59
ЖЕЛЕЗНЫЙ КОРОЛЬ
Рет қаралды 7 МЛН