Тёмный

Java 8 Stream - How to Sort a List using lambda | Example | Java Techie 

Java Techie
Подписаться 180 тыс.
Просмотров 60 тыс.
50% 1

This video explain you How to sort a list in java 8 using lambda expression and stream API even we use Comparator for custom sorting order with stream api - real time example
GitHub:
github.com/Jav...
Blogs:
javagyanmantra...
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

Опубликовано:

 

26 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 90   
@Technoverse_software_solutions
@Technoverse_software_solutions 5 месяцев назад
Your explanation was simply superb.......................#CRISTAL CLEAR #take_a_bow
@oguzhan2393
@oguzhan2393 2 года назад
you are really doing great things. I was watching a guy who was really idiot. called amigo. something. But mate you are really doing good things thanks.
@Javatechie
@Javatechie 2 года назад
Thanks buddy glad that i am delivering the content which people can understand. Keep learning
@vandana89100
@vandana89100 3 года назад
Hats off to you for making life easier👍🏻
@nameshd658
@nameshd658 3 года назад
Wow man... I'm doing your programming series one by one every day... This is day #7.. Thanks a lot bro. Awesome tutorial !!!
@BooSgu
@BooSgu 2 года назад
Simple explanation and easy to understand. Thank you very much.
@subhashsahu9930
@subhashsahu9930 4 месяца назад
Thanks for sharing this valuable knowledge
@fjkldhakljf
@fjkldhakljf Год назад
Great work sir , I admire your ability to give motivation for examples and follow through steps of why this way is better than alternatives
@Javatechie
@Javatechie Год назад
Keep learning 😃
@saurabh7489
@saurabh7489 2 года назад
Great video. Thank you very much. Here is what I do for a list of objects: employees.sort(Comparator.comparing(Employee::getSalary)); employees.sort(Comparator.comparing(Employee::getSalary).reversed());
@Javatechie
@Javatechie 2 года назад
It's always recommend to use stream in single pipeline rather than use collections utility method
@saurabh7489
@saurabh7489 2 года назад
@@Javatechie Thanks for the information 🙂 I just felt that if all I want to do is sort the stream and not worry about modifying the original list, and not perform any other operation like 'filtering' or 'mapping' then creating a stream will incur extra overhead.
@BookWormsOriginal
@BookWormsOriginal 4 года назад
The most simplistic and to the point explanation, you made my day! Thanks a lot! You deserve to be subscribed to!
@Javatechie
@Javatechie 4 года назад
Thank you so much subham
@siyedyoussef3202
@siyedyoussef3202 5 лет назад
Great java 8 playlist video 👍👍👍👍
@amitkharbade
@amitkharbade 3 года назад
Thanks for another useful tutorial
@debaprasadsahoo3707
@debaprasadsahoo3707 5 лет назад
Really this is a very good explanation for me.
@mohammedshabbir1347
@mohammedshabbir1347 4 года назад
Awesome explanation. Thanks Basant.
@mydreamworld29
@mydreamworld29 3 года назад
Well explained. Thanks
@taufiquealam4125
@taufiquealam4125 5 лет назад
You are simply Wow. Nice explanation. Request to come up with new things in Java 8 that would be highly appreciated.
@Javatechie
@Javatechie 5 лет назад
After finish this stream API we will start date API series
@taufiquealam4125
@taufiquealam4125 5 лет назад
@@Javatechie Thank you...
@manimarankrishnamoorthy8172
@manimarankrishnamoorthy8172 4 года назад
Nicely explained..Great.
@neutral911
@neutral911 4 года назад
Excellent Bro... I'm very satisfied with this explanation.. Thanks a lot and keep posting videos...
@kishordige4654
@kishordige4654 2 года назад
Thank you! You are a great Teacher
@baibhavghimire3827
@baibhavghimire3827 4 года назад
You deserve more subscription..I am doing that..Thanks man for going through the basis and connecting dots.
@umaparvathi606
@umaparvathi606 3 года назад
All the topics very nice sir
@niranjanp8194
@niranjanp8194 2 года назад
Perfect example bro. keep it up.
@mohan4459
@mohan4459 5 лет назад
Nice explanation ... Thank you so much
@berkcanulubas1318
@berkcanulubas1318 4 месяца назад
thank you for your great video
@sumitjain3526
@sumitjain3526 2 года назад
Thank you so much
@sureshsadanala4639
@sureshsadanala4639 5 лет назад
nicely explained 👍.. waiting for more videos 😊
@TheMihan123
@TheMihan123 5 лет назад
Thanks ! nicely explained .
@sarojgupta8181
@sarojgupta8181 2 года назад
wow its superb :)
@Javatechie
@Javatechie 2 года назад
Thanks buddy 😊
@ramanshrestha3851
@ramanshrestha3851 3 года назад
Nice video, keep uploading useful videos related to Java. Thanks
@ANKITCHOUDHARYankitkrchy
@ANKITCHOUDHARYankitkrchy 2 года назад
Commendable job
@milimishra6447
@milimishra6447 3 месяца назад
Good one
@tussharsurya5829
@tussharsurya5829 5 лет назад
Well explained 😇
@Sp_Travel_Vlogs07
@Sp_Travel_Vlogs07 Год назад
NYC video 17:18 ❤
@sowmyadara
@sowmyadara 4 года назад
Great explanation.. at 2:58 why can't we use like sorted(Comparator::reveseOrder)
@Javatechie
@Javatechie 4 года назад
We can't represent this as Method reference
@sowmyadara
@sowmyadara 4 года назад
@Java Techie ... Thank you
@sinurao1017
@sinurao1017 3 года назад
Super JT
@naveenc4963
@naveenc4963 5 лет назад
Nice explanation bro Can you share the Java 8 features example codes
@Javatechie
@Javatechie 5 лет назад
Link mentioned in video description
@pankajkm884
@pankajkm884 3 года назад
getName method is not static method. It is instance method. So, how you can call it by Class reference method?
@Javatechie
@Javatechie 3 года назад
Method reference doesn't mean to access only static method all getter method you can access while performing mapping
@Saravanan-lj9so
@Saravanan-lj9so 4 года назад
Man, Why you did not put video 15 years back ?I would have been very good developer.You are great.
@Javatechie
@Javatechie 4 года назад
Thank you 😀
@rahulkaranjavkar7994
@rahulkaranjavkar7994 5 лет назад
Thanks...
@vipinvenugopal3166
@vipinvenugopal3166 2 года назад
Thanks
@pradiptagure7492
@pradiptagure7492 4 года назад
Very good tutorial. It helped me. But one question, at the comparing example, it is sorting ascending by default. If I need to do, descending as well, how to achieve that?
@Javatechie
@Javatechie 4 года назад
You can call reverseOrder ()
@pradiptagure7492
@pradiptagure7492 4 года назад
@@Javatechie Thanks
@RaulSC9
@RaulSC9 4 года назад
Thanks!!
@hardikjotangia2642
@hardikjotangia2642 4 года назад
Sir, when I am doing shorting I want new shorted list, How to achieve this?
@Javatechie
@Javatechie 4 года назад
Yes we can , you need to do something like list.stream().sort(Comparator.comparing("ADD COMPARISON LOGIC")).collect(Collectors.toList());
@RealSlimShady-um6gf
@RealSlimShady-um6gf 11 месяцев назад
While sorting why do you want to downcast Long to int? Either while declaring the field you should have made it as int or proceed with logic for Long which is a much better real time example
@saswatidas6217
@saswatidas6217 5 лет назад
Could you please explain more about method reference ?
@raghunathhembram9962
@raghunathhembram9962 11 месяцев назад
sir can we sort the list of number without using sorted method by using stream api in java
@Javatechie
@Javatechie 11 месяцев назад
import java.util.List; import java.util.ArrayList; import java.util.stream.Collectors; import java.util.Comparator; public class Main { public static void main(String[] args) { List numbers = List.of(3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5); List sortedNumbers = new ArrayList(); while (!numbers.isEmpty()) { Integer min = numbers.stream() .min(Comparator.naturalOrder()) .orElse(null); if (min != null) { sortedNumbers.add(min); numbers.remove(min); } } System.out.println(sortedNumbers); } }
@vishalpradhan9881793197
@vishalpradhan9881793197 3 года назад
writing comment from UI
@vishalpradhan9881793197
@vishalpradhan9881793197 3 года назад
writing comment from terminal
@kishyash1
@kishyash1 2 года назад
Hii vasant, how will we do customized sorting in descending order using method reference ? (Comparator.comparing(Employee::getName)). This will give me sorting in ascending order but i want in descending order.
@Javatechie
@Javatechie 2 года назад
Just use reversed () method
@kishyash1
@kishyash1 2 года назад
@@Javatechie Thanks alot and response also so fast
@Javatechie
@Javatechie 2 года назад
Is it works?
@kishyash1
@kishyash1 2 года назад
@@Javatechie yes
@johngather4055
@johngather4055 4 года назад
thnks why u are overriding equals and hashcode for custom employee
@Javatechie
@Javatechie 4 года назад
If you won't override equals and hashcode then we can't compare object This is what also contract between these two method
@vamsikondaparthik9934
@vamsikondaparthik9934 2 года назад
Thanks for the Tutorial. In Java 11 i am unable to call getter and setter methods in comparing method like below: listEmployee.stream().sorted(Comparator.comparing(emp->emp.getName) Could you please help me with this.
@Javatechie
@Javatechie 2 года назад
Do you have setter and getter method define in your employee class
@vamsikondaparthik9934
@vamsikondaparthik9934 2 года назад
@@Javatechie i think its just STS not showing the methods … when i wrote manually there is no error
@sujithg5873
@sujithg5873 5 лет назад
Can u detailed explanation for method reference
@Javatechie
@Javatechie 5 лет назад
Ok Will do
@sujithg5873
@sujithg5873 5 лет назад
@@Javatechie thanks ☺️☺️
@ashishchoudhary9824
@ashishchoudhary9824 3 года назад
Hii vasant, how will we do customized sorting in descending order using method reference ? (Comparator.comparing(Employee::getName)). This will give me sorting in ascending order but i want in descending order. Or i want sorting based on length of employee name, how will do using stream api ? Thanks.
@Ravinanik
@Ravinanik 10 месяцев назад
How to sort reverse using comparing method
@saurabhkailashchandrapuran8609
@saurabhkailashchandrapuran8609 3 года назад
how to sort on custom two fields like with name and salary both at a time
@Javatechie
@Javatechie 3 года назад
Inside lambda we need to go for if condition
@Ankit-vp7nt
@Ankit-vp7nt 4 года назад
Bro search by name and name has casesensitive means some name start with upper case then how to sort in video 15:15 min
@Javatechie
@Javatechie 4 года назад
Why doing stream you should forcefully either make them lowercase or uppercase something like employees.stream().sorted(Comparator.comparing(emp->emp.getName().toLowerCase())).forEach(System.out::println);
@Ankit-vp7nt
@Ankit-vp7nt 4 года назад
@@Javatechie Collections.sort(employee,(o1,o2)-> o1.getName().compareToIgnoreCase(o2.getName())); like that working but in stream is not working
@Javatechie
@Javatechie 4 года назад
@@Ankit-vp7nt let you know once I will check
@sanketprajakta
@sanketprajakta Месяц назад
nice explanation👌
@maruthidanda2364
@maruthidanda2364 3 года назад
Super super
@ILuvBilli
@ILuvBilli 5 лет назад
Superbbbb
@omsonschicago5872
@omsonschicago5872 4 года назад
Thank you so much
@sameer838
@sameer838 2 года назад
Great
Далее
Brilliant Budget-Friendly Tips for Car Painting!
00:28
#95 Comparator vs Comparable in Java
15:43
Просмотров 183 тыс.
Stream API in Java
26:04
Просмотров 330 тыс.
#7 - How to Compare Two ArrayLists in Java
10:31
Просмотров 53 тыс.
Sort HashMap By Value Java8
6:17
Просмотров 6 тыс.
Dear Functional Bros
16:50
Просмотров 509 тыс.