Java Coding Interview Questions and Answers | Sorting using comparator | Code Decode | [Most Common]

preview_player
Показать описание
In this video of code decode we have covered sorting using comparator which is common in Java coding interview question and answers for experienced

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

Course Description Video :

Write a Comparator in Java to compare two employees based upon name, age and Address?

This Programming Interview Question is very commonly asked for Experienced Java software developers.

In order to sort Employee object on different criteria, we need to create multiple comparators e.g. NameComparator, AgeComparator, and AddressComparator, this is known as custom sorting in Java.

Compare method returns
Negative if 1st parameter is 2nd parameter
Positive if 1st parameter is 2nd parameter
0 if 1st parameter is = 2nd parameter

This is also a very popular hackerrank problem which Interviewer asked you solved as a Experienced Java Developer

Ordering objects of user-defined classes is done using a comparator interface. A comparator object can compare two objects that belong to the same class. Compare obj1 and obj2 using the following function.

A user-defined class's objects are ordered using the Java Comparator interface.

It supports different sorting sequences, which means you can order the items by any data member, such as rollno, name, age, or anything else.

Subscriber and Follow Code Decode

#codedecode #javacodinginterviewquestion #javainterviewquestion
Рекомендации по теме
Комментарии
Автор

These videos helped me in getting placements

ganjinagaudaykiran
Автор

just wanted to say thank you for all the videos you made, I just got my first job offer as a junior software engineer and I used a lot of your videos to prepare for the interview. Thank you for the help sharing your knowledge!

jorgeayestas
Автор

I cannot praise you enough for making these knowledgeable videos

aditigupta
Автор

Excellent explanation 👌🏻 Recently I have started following this channel and many things got clarified. As an experienced Java developer, Im facing many tricky question in almost all topics : Core Java 6&8, spring, Springboot, Microservices, SQL etc... For my current job search I'm going through this channel only for reference... Really helpful 🙏🏻 Expecting more scenario based questions and answers also more design pattern and Microservices interview questions also. If you've covered already I'll check it else pls try to upload the tricky questions in these areas too ..

nandhinidevij
Автор

Please carry forward this series … the future questions seems really promising

vanshikamalhotra
Автор

This channel is gold 🔥
Enough for cracking interviews,
Please continue the uploads and have a playlist on springboot annotations and their working 👍

shubhamkumar-gwvb
Автор

Best channel for learning and implement coding ...

kaushalgupta
Автор

Hi codedecode, Thank you so much. Your videos have really helped in my interview prep, I have 2 job offers now
Your videos are too good

dhanyav
Автор

Thanks for this video and please share the link for the next part of this video

mohammedsufi
Автор

Hi code decode team
I have watched almost all of ur videos to prepare for interview along with some others. Thanks to ur way of making thing easy I gave interview for 17 companies and cracked offer of around 10 with maximum hike of approx 220%.

reshusinghal
Автор

Great thanks. Awesome videos as always.

rishiraj
Автор

Your videos are really covering great content they are really helpful. Only one feedback I would like to give is, kindly go little slow including the mouse movement on the screen so that it would be helpful to new to Java users like me 😊. I really appreciate your content.

padmahastha
Автор

You are still gaining subscribers because your teaching skills excellent💯👍

TECH_JAIPAL
Автор

Please continue and add video for creating a deadlock situation in Java

syedr
Автор

Please carry forward this series.it will really beneficial in interview

swapnshilkhadse
Автор

Thank you for your great stuff and presentaion

jeganp
Автор

Please carry forward for next codeing questions....

indlasubramanyam
Автор

madam make a vedeo java program to prevent deadlock in java.tq for ur vedeos its very interesting and happy to learn.

rachamallidorasrivignesh
Автор

Great Content. But need one help regarding AddressComparator..how it was prepared ? If I prepare
AddressComparator implements Comparable<Address> then in Main class it is not possible to use :
Collections.sort(employeelist, new AddressComparator());

aniketvitekar
Автор

Thanks for making interview preparations easier🙏

KrishnaKumar-vxwo