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

  Рет қаралды 62,253

Java Techie

Java Techie

Күн бұрын

Пікірлер: 90
@vipinvenugopal3166
@vipinvenugopal3166 2 жыл бұрын
Thanks
@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 !!!
@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
@vandana89100
@vandana89100 3 жыл бұрын
Hats off to you for making life easier👍🏻
@Technoverse_software_solutions
@Technoverse_software_solutions 9 ай бұрын
Your explanation was simply superb.......................#CRISTAL CLEAR #take_a_bow
@baibhavghimire3827
@baibhavghimire3827 4 жыл бұрын
You deserve more subscription..I am doing that..Thanks man for going through the basis and connecting dots.
@BooSgu
@BooSgu 2 жыл бұрын
Simple explanation and easy to understand. Thank you very much.
@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 😃
@neutral911
@neutral911 5 жыл бұрын
Excellent Bro... I'm very satisfied with this explanation.. Thanks a lot and keep posting videos...
@niranjanp8194
@niranjanp8194 2 жыл бұрын
Perfect example bro. keep it up.
@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...
@mohammedshabbir1347
@mohammedshabbir1347 4 жыл бұрын
Awesome explanation. Thanks Basant.
@umaparvathi606
@umaparvathi606 3 жыл бұрын
All the topics very nice sir
@siyedyoussef3202
@siyedyoussef3202 5 жыл бұрын
Great java 8 playlist video 👍👍👍👍
@saurabh7489
@saurabh7489 3 жыл бұрын
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 3 жыл бұрын
It's always recommend to use stream in single pipeline rather than use collections utility method
@saurabh7489
@saurabh7489 3 жыл бұрын
@@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.
@debaprasadsahoo3707
@debaprasadsahoo3707 5 жыл бұрын
Really this is a very good explanation for me.
@kishordige4654
@kishordige4654 2 жыл бұрын
Thank you! You are a great Teacher
@subhashsahu9930
@subhashsahu9930 7 ай бұрын
Thanks for sharing this valuable knowledge
@sanketprajakta
@sanketprajakta 4 ай бұрын
nice explanation👌
@sureshsadanala4639
@sureshsadanala4639 5 жыл бұрын
nicely explained 👍.. waiting for more videos 😊
@manimarankrishnamoorthy8172
@manimarankrishnamoorthy8172 4 жыл бұрын
Nicely explained..Great.
@amitkharbade
@amitkharbade 3 жыл бұрын
Thanks for another useful tutorial
@Gagana_Tgk
@Gagana_Tgk 5 жыл бұрын
Nice explanation ... Thank you so much
@mydreamworld29
@mydreamworld29 3 жыл бұрын
Well explained. Thanks
@ANKITCHOUDHARYankitkrchy
@ANKITCHOUDHARYankitkrchy 2 жыл бұрын
Commendable job
@ramanshrestha3851
@ramanshrestha3851 3 жыл бұрын
Nice video, keep uploading useful videos related to Java. Thanks
@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
@TheMihan123
@TheMihan123 5 жыл бұрын
Thanks ! nicely explained .
@berkcanulubas1318
@berkcanulubas1318 7 ай бұрын
thank you for your great video
@OffRoadEngineerVlogs
@OffRoadEngineerVlogs Жыл бұрын
NYC video 17:18 ❤
@sarojgupta8181
@sarojgupta8181 2 жыл бұрын
wow its superb :)
@Javatechie
@Javatechie 2 жыл бұрын
Thanks buddy 😊
@tussharsurya5829
@tussharsurya5829 5 жыл бұрын
Well explained 😇
@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
@sameer838
@sameer838 2 жыл бұрын
Great
@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
@milimishra6447
@milimishra6447 7 ай бұрын
Good one
@omsonschicago5872
@omsonschicago5872 4 жыл бұрын
Thank you so much
@ILuvBilli
@ILuvBilli 5 жыл бұрын
Superbbbb
@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
@maruthidanda2364
@maruthidanda2364 3 жыл бұрын
Super super
@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 😀
@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
@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());
@rahulkaranjavkar7994
@rahulkaranjavkar7994 5 жыл бұрын
Thanks...
@raghunathhembram9962
@raghunathhembram9962 Жыл бұрын
sir can we sort the list of number without using sorted method by using stream api in java
@Javatechie
@Javatechie Жыл бұрын
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); } }
@Ravinanik
@Ravinanik Жыл бұрын
How to sort reverse using comparing method
@RaulSC9
@RaulSC9 5 жыл бұрын
Thanks!!
@saswatidas6217
@saswatidas6217 5 жыл бұрын
Could you please explain more about method reference ?
@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
@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.
@RealSlimShady-um6gf
@RealSlimShady-um6gf Жыл бұрын
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
@johngather4055
@johngather4055 5 жыл бұрын
thnks why u are overriding equals and hashcode for custom employee
@Javatechie
@Javatechie 5 жыл бұрын
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 ☺️☺️
@saurabhkailashchandrapuran8609
@saurabhkailashchandrapuran8609 4 жыл бұрын
how to sort on custom two fields like with name and salary both at a time
@Javatechie
@Javatechie 4 жыл бұрын
Inside lambda we need to go for if condition
@vishalpradhan9881793197
@vishalpradhan9881793197 3 жыл бұрын
writing comment from terminal
@vishalpradhan9881793197
@vishalpradhan9881793197 3 жыл бұрын
writing comment from UI
@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
@sumitjain3526
@sumitjain3526 2 жыл бұрын
Thank you so much
Lambda Expressions in Java - Full Simple Tutorial
13:05
Coding with John
Рет қаралды 785 М.
Каха и дочка
00:28
К-Media
Рет қаралды 3,4 МЛН
1% vs 100% #beatbox #tiktok
01:10
BeatboxJCOP
Рет қаралды 67 МЛН
Java 8 Stream API | forEach & filter Method example | Java Techie
21:56
Method Reference In Java 8 - How it really works ?
1:20:27
Selenium Express
Рет қаралды 8 М.
28. Streams in Java8 | Collections in Java - Part7
1:15:10
Concept && Coding - by Shrayansh
Рет қаралды 62 М.
Dependency Injection, The Best Pattern
13:16
CodeAesthetic
Рет қаралды 904 М.
Sort HashMap By Value Java8
6:17
CloudTech
Рет қаралды 7 М.
Java 8 Streams | Optional Usage and Best Practices | JavaTechie
22:22
16. Functional Interface and Lambda Expression - Java8 features | Java Interfaces Part3
31:32
Concept && Coding - by Shrayansh
Рет қаралды 37 М.