Тёмный

Java 8 Stream Collectors groupingBy Example | Java 8 coding Interview Questions & Answer|Code Decode 

Code Decode
Подписаться 127 тыс.
Просмотров 107 тыс.
50% 1

In this video of code decode we have demonstrated how we can do Group By in java 8 same as we do in SQL using Group By Clause in SQL Queries. Its java 8 Group By coding interview questions of java 8 using collectors and grouping by concept.
Udemy Course of Code Decode on Microservice k8s AWS CICD link:
openinapp.co/udemycourse
Course Description Video :
yt.openinapp.co/dmjvd
Why do we need Grouping Collector?
Given a stream of objects, there are scenarios where these objects need to be grouped based on a certain distinguishing characteristic they posses.
E.G. -
Create a map with key as Age and value as list of employees in that age group.
This concept of grouping is the same as the ‘group by’ clause in SQL which takes an attribute, or a calculated value derived from attribute(s), to divide the retrieved records in distinct groups.
Generally what we used to do to group by is -
iterating over each object, checking which group the object being examined falls in, and then adding that object in its correct group. The group itself is held together using a Collection instance.
grouping collector with single parameter
The classification function passed to groupingBy() method is the method specified as "Employee.getAge()".
As the end result of applying the grouping collector for achieving this we want a Map with keys as age and corresponding values as List of employees of that age.
2 parameter Collectors.groupingBy()- uses a user specified Collector to collect grouped elements
Whereas the 1st variant always returned a List containing the elements of a group, the 2nd variant of grouping collector provides the flexibility to specify how the grouped elements need to be collected using a second parameter which is a Collector.
So, instead of just storing the groups in resultant Map as Lists, we can instead store them in say Sets,
(Collectors.groupingBy(Employee.getAger(), Collectors.toSet()));
Most Asked Core Java Interview Questions and Answers : • Core Java frequently a...
Advance Java Interview Questions and Answers : • Advance Java Interview...
Java 8 Interview Questions and Answers : • Java 8 Interview Quest...
Hibernate Interview Questions and Answers : • Hibernate Interview Qu...
Spring Boot Interview Questions and Answers : • Advance Java Interview...
Angular Playlist : • Angular Course Introdu...
SQL Playlist : • SQL Interview Question...
GIT : • GIT
Subscriber and Follow Code Decode
Subscriber Code Decode : ru-vid.com?...
Linkedin : / codedecodeyoutube
Instagram : / codedecode25
#codedecode #java8collectorsAndGroupingby #java8interviewquestionsandanswers

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

 

22 мар 2022

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 139   
@flight_of_phoenix
@flight_of_phoenix Год назад
Very good tutorial. I appreciate your hard work. Not many places we get such knowledge from. Thank you very much!
@CodeDecode
@CodeDecode Год назад
Thanks a lot Nikhil🙂👍
@akshaykalyankshatriya8832
@akshaykalyankshatriya8832 Год назад
Ç
@deepalimalviya6387
@deepalimalviya6387 Год назад
Initially it was very difficult for me to understand grouping by functionality, but you made it very simple, thank you so much and please keep making such videos, they are really helpful for us.
@CodeDecode
@CodeDecode Год назад
Thanks Deepali. Glad at least you put efforts in learning these concepts 👏it will help you coding better👏👏👏
@sheiksahil7209
@sheiksahil7209 2 года назад
Thank you so much for your Lectures and hard work. Your videos should get more recognitions. By learning from your channel have been able to crack my 1st offer with 8 LPA. Thank you again and keep providing the knowledge.
@CodeDecode
@CodeDecode 2 года назад
Many congratulations Sheik. 🎉🎉🎉🎉👏👏 Well deserved Man👏👏. Keep rocking
@fewminuteswithanand
@fewminuteswithanand Год назад
You are the best mam. This is the first well-explained video I found on youtube for all 3 grouping by methods. Thank you, mam.
@CodeDecode
@CodeDecode Год назад
Thanks a lot Anand 🙂🙂
@akashsaha9366
@akashsaha9366 2 года назад
Just excellent knowledge video. Pompous!!!👍
@CodeDecode
@CodeDecode 2 года назад
Thanks Akash 🙂👍
@sathishreddy4010
@sathishreddy4010 2 года назад
I watched almost all your training videos. Excellent explanation Madam 👍👌. Please continue creating videos. Keep up the good work.
@CodeDecode
@CodeDecode 2 года назад
Thanks Sathish 🙂👍
@ajitdighe3293
@ajitdighe3293 10 месяцев назад
Thanks for this video !!!! Appreciate the efforts taken to explain the problem and solution....Very few people does this....Please keep explaining this way.
@CodeDecode
@CodeDecode 9 месяцев назад
Thanks Ajit 😊😊👍
@shamilraj7511
@shamilraj7511 2 года назад
Excellent video. Thank you so much Mam and the entire team. Keep up the good work. 👍
@CodeDecode
@CodeDecode 2 года назад
Thanks Shamil
@kalekar100
@kalekar100 2 года назад
This is awesome. Please keep posting such questions on streams. It is really helpful for me in interviews
@CodeDecode
@CodeDecode 2 года назад
Sure Sourabh. We will do that 🙂🙂👍👍
@febasamuel1583
@febasamuel1583 10 месяцев назад
Its very clear. Thankyou for the detailed explanation
@CodeDecode
@CodeDecode 10 месяцев назад
Glad it was helpful!
@uditsankhadasariya5718
@uditsankhadasariya5718 2 года назад
Amazing content. Love the way it is presented and explained in depth. Best I've ever seen on RU-vid. Can you give us a link to the google slide presentation that contains everything presented in these RU-vid videos about Java?
@jskr456
@jskr456 11 месяцев назад
loved the way how you make it simple and explain it
@CodeDecode
@CodeDecode 11 месяцев назад
Thanks
@arslanahsan5680
@arslanahsan5680 2 года назад
you are awesome . your teaching method is very good
@CodeDecode
@CodeDecode 2 года назад
Thanks Arslan 🙂🙂👍👍
@Suraj-dj5rk
@Suraj-dj5rk 4 месяца назад
Thank you so much for the video❤.. much needed
@CodeDecode
@CodeDecode 4 месяца назад
You are welcome!
@arthiarulkumar8289
@arthiarulkumar8289 2 года назад
Please continue doing videos like this... It's very useful. Kindly upload videos for spring boot tutorial
@CodeDecode
@CodeDecode 2 года назад
Sure Arthi. We will do that 🙂🙂 Thanks 🙂👍
@user-kk1om1wf9p
@user-kk1om1wf9p Год назад
At first i was confused on groupingby parameters that you have given only one parameter i.e., getAge() and i don't know how it groups by list. But after watching @9:47 i understand how it collect as a list. Thanks for the deep explanation ❤🙏✨
@CodeDecode
@CodeDecode Год назад
Glad to hear that 🙂👍
@sankarasubramanian568
@sankarasubramanian568 Год назад
Great content, thank you so much :)
@CodeDecode
@CodeDecode Год назад
🙂🙂👍👍
@himanshurana5213
@himanshurana5213 Год назад
Your videos are the best
@CodeDecode
@CodeDecode Год назад
❤❤🙂🙂
@yogendrasingh-nz3pw
@yogendrasingh-nz3pw 4 месяца назад
Thanks a lot mam for this teach us this complex concept.🙏🙏
@CodeDecode
@CodeDecode 4 месяца назад
😊😊👍👍
@user-cu5pf4yo8c
@user-cu5pf4yo8c Месяц назад
Wow Superb explanation
@CodeDecode
@CodeDecode Месяц назад
Thanks 😊
@dipaliyadav-koli1060
@dipaliyadav-koli1060 Год назад
OMG.. You are super talented girl.. ❤️ Very helpful video. Thank you for sharing.
@CodeDecode
@CodeDecode Год назад
Thanks Dipali. Means a lot to me🙂 ☺
@BrianBest
@BrianBest Год назад
Thank you for this!
@CodeDecode
@CodeDecode Год назад
🙂🙂 👍👍
@sonuraghuwanshi5672
@sonuraghuwanshi5672 2 года назад
Great job 👍
@CodeDecode
@CodeDecode 2 года назад
Thanks Sonu 🙂👍
@manashranjan1267
@manashranjan1267 Год назад
Nicely explanation madam it cleared my all doughts
@CodeDecode
@CodeDecode Год назад
Glad to hear that Manas 👍🙂
@mrindian7422
@mrindian7422 5 месяцев назад
Very nicely explained
@CodeDecode
@CodeDecode 5 месяцев назад
Thanks
@adarshverma3372
@adarshverma3372 Год назад
Great explanation
@CodeDecode
@CodeDecode Год назад
Thanks Adarsh 😇👍👍
@yogesh_mehra
@yogesh_mehra 6 месяцев назад
Great Content👍
@CodeDecode
@CodeDecode 6 месяцев назад
Thank you
@chandugaddam4985
@chandugaddam4985 2 года назад
Good content 👏👏👏
@CodeDecode
@CodeDecode 2 года назад
Thanks
@ahishnar1568
@ahishnar1568 2 года назад
Amazing 👍
@CodeDecode
@CodeDecode 2 года назад
Thanks
@deepa8177
@deepa8177 Год назад
so good tutorial🔥, explaining each point relating with project, also with how it will be with 2 params, showing json views, all in 1 video, got so much to learn from this video🔥🔥🔥, thnku so much🤗, just 1 question how do we understand the source code so well? coj some terminologies are not understandable
@livelifetoday373
@livelifetoday373 2 месяца назад
Thanks for sharing
@CodeDecode
@CodeDecode 2 месяца назад
👍😊
@AshishSingh-rx4sq
@AshishSingh-rx4sq 2 года назад
Fire!
@CodeDecode
@CodeDecode 2 года назад
Thanks Ashish 🙂🙂
@ankita.narang
@ankita.narang 5 месяцев назад
Thank you for the amazing video, please suggest how to do reverse sorting with grouping by.
@aparnageete5693
@aparnageete5693 Год назад
Thank you for sharing knowledge. You are doing awesome. I want notes of your videos. How can I get that?
@paridadeepika
@paridadeepika 10 месяцев назад
very helpful....
@CodeDecode
@CodeDecode 10 месяцев назад
👍 thanks 👍
@amer6339
@amer6339 Год назад
Thanks!
@CodeDecode
@CodeDecode Год назад
Thanks Amer !!! :)
@sumit5624
@sumit5624 2 года назад
Thank you Ma'am
@CodeDecode
@CodeDecode 2 года назад
🙂🙂👍👍
@abiz504
@abiz504 8 месяцев назад
very good tutorial
@CodeDecode
@CodeDecode 8 месяцев назад
Thanks
@paridadeepika
@paridadeepika 10 месяцев назад
nice one...
@CodeDecode
@CodeDecode 10 месяцев назад
🙂
@MarimuthuNagappan-oe8lq
@MarimuthuNagappan-oe8lq Год назад
Excellent
@CodeDecode
@CodeDecode Год назад
Thanks
@abiultimate
@abiultimate 2 года назад
Superb
@CodeDecode
@CodeDecode 2 года назад
Thanks Abirami 🙂🙂👍👍❤
@rushikeswararaopolaki3602
@rushikeswararaopolaki3602 9 месяцев назад
Nice video madam, keep it up
@CodeDecode
@CodeDecode 9 месяцев назад
Thanks
@ibrahimsathick1543
@ibrahimsathick1543 Год назад
I love ur voice mam
@sairaj5613
@sairaj5613 10 месяцев назад
Could you let us know which approach is better, 1. Using groupingBy() or 2. Retrieving the data from SQL using Group by, provided we have a chance to use any of them
@tannubajpai4782
@tannubajpai4782 Год назад
awsm ma'am
@CodeDecode
@CodeDecode Год назад
Thanks
@tannubajpai4782
@tannubajpai4782 Год назад
Can u give solution of frequency of character which has not frequncy 2
@devendra.sanghavi
@devendra.sanghavi Год назад
thanks dear
@CodeDecode
@CodeDecode Год назад
Thanks😇
@AshishSingh-rx4sq
@AshishSingh-rx4sq 2 года назад
Always feel like My manager is teaching me. :)
@CodeDecode
@CodeDecode 2 года назад
Thanks Ashish🙂🙂. Who is your manager. I never heard in my whole career that manager puts input to make employees learn . I truely appreciate your manager if she / he does that. Value her. In upcoming yours you will see loads of non technical managers who will just scrap your head if task is not completed in time. Tell her we as a community respect him/ her 🙏🙏🙂🙂
@AshishSingh-rx4sq
@AshishSingh-rx4sq 2 года назад
@@CodeDecode with resemblance I meant the voice tone, anyways exceptions are always there, there are few good managers too but only a few, but yes completely agreed with you.
@sayanbiswas8847
@sayanbiswas8847 2 года назад
helpful
@CodeDecode
@CodeDecode 2 года назад
Thanks sayan 🙂🙂👍👍
@RahulMishra-rmRishu
@RahulMishra-rmRishu 2 года назад
👌
@CodeDecode
@CodeDecode 2 года назад
🙂🙂
@sakshamsaigal7012
@sakshamsaigal7012 10 месяцев назад
Thanks for a beautiful explaination @CodeDecode Just one question : Suppose we want the grouping to be in descending order, how can we use treeMap here?
@CodeDecode
@CodeDecode 9 месяцев назад
You can use it with comparator in reverse order (-)
@pankajsharma31
@pankajsharma31 2 года назад
Awesome, can you create some video on completable future and Transaction in Spring boot
@CodeDecode
@CodeDecode 2 года назад
Nice topic Sunny. Sure we will do that 👍👍
@neenadevasia7012
@neenadevasia7012 Месяц назад
Super good tutorials!! Really helpful. Could you please let me know, if you have tutorials for restful api's in java using spring boot?
@neenadevasia7012
@neenadevasia7012 Месяц назад
Thank You soo much for the tutorials!! Do you have a course on restful api's in java using spring boot on any platform?
@CodeDecode
@CodeDecode Месяц назад
Thanks. They are on the channel only 👍
@ArjunSingh-is1bg
@ArjunSingh-is1bg 2 года назад
by the way you have nice voice
@CodeDecode
@CodeDecode 2 года назад
Thanks Arjun 🙂🙂👍👍
@atuljain5539
@atuljain5539 2 года назад
your voice is nice
@CodeDecode
@CodeDecode 2 года назад
Thanks Atul 🙂👍
@ShinAkuma
@ShinAkuma 2 года назад
The more I learn Streams, the more complex they get. Please make a tutorial on how to Group by multiple fields and use aggregate functins along with it. For example: Count the number of employees department wise along with the total of each employee's salary. The result would be like, DepartmentIID----NumberOfEmployees----TotalSalary 101.......................20...................................10000 102.......................15...................................27000 and so on.. And how to create multiple fields with aggregate functions, like I want Total Salary, Average Salary and Max Salary etc.. columns in the result as well.
@CodeDecode
@CodeDecode 2 года назад
Yes it does seems complicated initially but once u know all methods , you will just have to aggregate and implement your knowledge and you will be good to go 🙂🙂. Sure grouping by with multiple fields is a good ques. We will put video on it 👍🙂🙂
@start1learn-n171
@start1learn-n171 4 месяца назад
Tq
@CodeDecode
@CodeDecode 4 месяца назад
Welcome
@asharudheenmannilthodi7496
@asharudheenmannilthodi7496 Год назад
i am new to this channel. what order you suggest for watching the videos. i am intrested in the java,hibernate,spring,springboot Please help
@sdubey0201
@sdubey0201 Год назад
good
@CodeDecode
@CodeDecode Год назад
Thanks
@ajitdighe3293
@ajitdighe3293 10 месяцев назад
Request you to make series on Java 8 features.
@CodeDecode
@CodeDecode 9 месяцев назад
Java 8 Interview Questions(New Features): ru-vid.com/group/PLyHJZXNdCXsdeusn4OM33415DCMQ6sUKy
@anuragarora2960
@anuragarora2960 Год назад
Hlo dear , that equals method is not needed to be called anywhere?
@rushikeshgodase8498
@rushikeshgodase8498 Год назад
Mam how to do in reverse order in grouping?
@radhikakodagali5312
@radhikakodagali5312 Год назад
At 1:45 you said previous video, can you share link of the previous video?
@CodeDecode
@CodeDecode Год назад
Java 8 Interview Questions(New Features): ru-vid.com/group/PLyHJZXNdCXsdeusn4OM33415DCMQ6sUKy
@yogendraamarji7285
@yogendraamarji7285 4 месяца назад
What if I want output in descending order
@GauravSingh-nt9vj
@GauravSingh-nt9vj 10 месяцев назад
do you have github repo for all these codes
@aakritigupta3105
@aakritigupta3105 2 года назад
I know my question is not related to this video, but please please please please help me. I have two oracle databases hosted on different servers, one of them requires SCHEMA_NAME. TABLENAME to generate result set. In my springboot project, i specified spring.jpa.properties.hibernate.default_schema=SCHEMA_NAME This property is setting this schema name for both datasources, which i dont want. I want only one datasource to use this schema name. I tried to put @Table( schema = SCHEMA_NAME) but it errors out. (though console query shows SCHEMA_NAME.TABLE_NAME) I using hikari. Please help me how to set two oracle database in Springboot using schema names. 😣😣😣😣😣
@pravinpawar1390
@pravinpawar1390 Год назад
Witch video Should watch before this video.
@CodeDecode
@CodeDecode Год назад
Here is list of all videos ru-vid.com/group/PLyHJZXNdCXsdeusn4OM33415DCMQ6sUKy
@paridhikhare1737
@paridhikhare1737 Месяц назад
claps
@amarthyaseshu683
@amarthyaseshu683 2 года назад
Grouping by reduces 50% of code I think 😀
@CodeDecode
@CodeDecode 2 года назад
Yes it does Amarthya 🙂🙂
@praffulpawarp7p372
@praffulpawarp7p372 10 месяцев назад
please reply what is your age when you learned all this means what is your total experience in java or it
@CodeDecode
@CodeDecode 10 месяцев назад
Why you need all these information ?
@praffulpawarp7p372
@praffulpawarp7p372 10 месяцев назад
@@CodeDecode you are too much talented I want to be like you
@CodeDecode
@CodeDecode 9 месяцев назад
We all are the team of working it professionals having> 8 years of experience in this industry 👍 and you are already doing a great job prafful, u don't need to be like any one. You rock 👏👏👍👍
@ILuvBilli
@ILuvBilli 2 года назад
Everything is fine here except repetition of "Nothing"
@CodeDecode
@CodeDecode 2 года назад
Fixed it in upcoming videos🙂👍
@shubhamkhandelwal7220
@shubhamkhandelwal7220 2 года назад
Aaj subh dal diya hota to m interview me select ho jata...aaj hi pucha interview me grouping😑
@CodeDecode
@CodeDecode 2 года назад
Koi naa next interview me yaad rahega. You will do good in next interview. M preety sure of that Shubham 🙂🙂👍👍 keep learning and you will for sure land atv your dream job soon. 👏👏
@shubhamkhandelwal7220
@shubhamkhandelwal7220 2 года назад
Thank you🙂
@testing12521
@testing12521 3 месяца назад
I garrenty you that she itself not understand underlying class files thats why she immediately moving files. 😂
@harshwardhanshetty4683
@harshwardhanshetty4683 3 месяца назад
yep
@ravikiran5207
@ravikiran5207 5 месяцев назад
Dear author , pls take some breath while speaking , she is keeping omn reading
Далее
СЫВОРОТКА С ВБ
00:39
Просмотров 672 тыс.