filmov
tv
Java Comparators Using Multiple Fields For Sorting Collections And List. Real life example explained

Показать описание
Java Comparators Using Multiple Fields For Sorting Collections And List. Solving one real world problem where we need to sort collections based on multiple fields in Java bean classes. Showing you with example how to do it in Eclipse session.
Sorting list of object based on multiple fields is very important when you are developing any enterprise level web applications. Because using this, we can present sorted data to the user as per his selection on the front end (where user can select how he wants the data to be sorted on the front end).
Also check out another video. Detailed explanation in Eclipse session :
Comparing List of Objects Using Multiple Fields Plain Java 8 Comparator Without Third Party Library
Interview Question: How do you sort list of objects in Java ? We have list of AccountHolder (in banking application) objects and we want to sort it based on their firstname and lastname. How do you sort this in Java?
//////////////////////////////// code snippet start ///////////////////////////////////////////////////////////////////////////////
public int compareTo(AccountHolder o) {
if (o == null) {
return -1;
}
CompareToBuilder buider = new CompareToBuilder();
}
Look in compareTo() how the CompareToBuilder builder pattern is used to dynamically create comparator using multiple fields of AccountHolder class's objects.
//////////////////////////////// code snippet end /////////////////////////////////////////////////////////////////////////////
If you find this video helpful, please 'Like' or 'Subscribe'.
This is really helpful for the channel and also motivates me to do more of such good videos.
#coding #softwareengineer #Leetcode #Algorithm #DataStructure #Java #programmer #tech #software #codinglife #Preparation
#interview #programminglife #programmingisfun #hashmap #ConcurrentHashMap #leetcode #codeforces #algorithm #algorithms #datastructure #datastructuresandalgorithms #programming #computerscience
#interviewpreparation #codingquestions #codinginterviewquestions #javaprogramming #javatutorial #codingquestions #javacollectionframework #javacollection #javacollections #javacollectionsframework
Sorting list of object based on multiple fields is very important when you are developing any enterprise level web applications. Because using this, we can present sorted data to the user as per his selection on the front end (where user can select how he wants the data to be sorted on the front end).
Also check out another video. Detailed explanation in Eclipse session :
Comparing List of Objects Using Multiple Fields Plain Java 8 Comparator Without Third Party Library
Interview Question: How do you sort list of objects in Java ? We have list of AccountHolder (in banking application) objects and we want to sort it based on their firstname and lastname. How do you sort this in Java?
//////////////////////////////// code snippet start ///////////////////////////////////////////////////////////////////////////////
public int compareTo(AccountHolder o) {
if (o == null) {
return -1;
}
CompareToBuilder buider = new CompareToBuilder();
}
Look in compareTo() how the CompareToBuilder builder pattern is used to dynamically create comparator using multiple fields of AccountHolder class's objects.
//////////////////////////////// code snippet end /////////////////////////////////////////////////////////////////////////////
If you find this video helpful, please 'Like' or 'Subscribe'.
This is really helpful for the channel and also motivates me to do more of such good videos.
#coding #softwareengineer #Leetcode #Algorithm #DataStructure #Java #programmer #tech #software #codinglife #Preparation
#interview #programminglife #programmingisfun #hashmap #ConcurrentHashMap #leetcode #codeforces #algorithm #algorithms #datastructure #datastructuresandalgorithms #programming #computerscience
#interviewpreparation #codingquestions #codinginterviewquestions #javaprogramming #javatutorial #codingquestions #javacollectionframework #javacollection #javacollections #javacollectionsframework