Java 8 Streams | map () & flatMap() Example | JavaTechie
ฝัง
- เผยแพร่เมื่อ 8 ก.พ. 2025
- This tutorial will guide you How & when to use map() and faltMap() method in java8 stream
#javatechie #java8 #Stream
GitHub:
github.com/Jav...
Blogs:
/ javatechie
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
Disclaimer/Policy:
--------------------------------
Note : All uploaded content in this channel is mine and its not copied from any community , you are free to use source code from above mentioned GitHub account
Thanks for making it look so simple. Key take away: If the parameter in the stream returns a Scalar(eg: customer.getEmail() single email id) then use Map. If the parameter returns a Vector(eg: customer.getPhoneNumbers(), customer.getProductsOrdered() which returns a list) then use FlatMap. Stream of Stream for FlatMap is one more key point to note...
I was unable to understand flatMap() until this video. Thank you so much Sir, your videos truly helps.
Thanks, man, your explanation is short and sweet without wasting time.
For anything I want to learn newly in java, I search for your videos! Awesome explanation. You're doing a great job! Thank you so much sir.
I watched multiple videos on this topic. But you are really very nice in explaining the things deeply with clear and right example. Thanks brother
This is a great tutorial, and it really helped clarify things for me! One minor issue: I'm pretty sure the term is "Data Flattening" not "Data Flattering" (though to be fair, data is not complemented nearly enough!)
For the first time i clearly understood flatmap(). Thanks a lot.
All doubts got cleared for differences between map and flatMap operations of stream API. Thanks
There's already SO many comments like this on this video, but I have to commend your ability to simply and clearly explain the topic. Showing an example that can implement both methods and even using the map on something you wanted to flatMap() to illustrate the need for the flatMap() method--such a good illustration.
Sure you said flattering instead of flattening but that is such a miniscule detail. Your comments in your code were fantastic too as it made your verbal explanations even more clear.
Much appreciated for this content, you just got a new subscriber!
Thanks buddy for the sweet word 👌
I have seen lots of videos but didn't understand but after see your video I understand very well thanks bro and God bless you 🙏
Amazing video: Few Highlights :
1. Use map function when we can map one-to-one mapping, whereas flatmap is used for one to many mapping.
2. map provides mapping for single input, single value whereas flatmap provides mapping single input multiple values
3. flat map performs data transformation+flattening(flattening is the process of converting multiple lists of lists in stream to a single list by merging the values)
No, it follow many-to-one mapping. It converts many collections one single stream
Please rename the word "flattering" to "flattening" . "Flattering" means to praise a lot,- lot of thumbs up for this video is flattering. Flattening is to reduce dimensions that flatMap does. Thanks
Yes buddy typo
SIMPLY and PPRECISLY explained!! Big Love for your Time, Effort and Diligences!!
everywhere people have complex definition. this one not only explained well but with a good example too.
Thanks for your clear explanation and dedication
Provided knowledge with simple example.
straight forward stunning explanation got concept easily.
You do it very well! Great explainations!! After this, all I understood is that decreasing object levels with flatmap to one level, gives a map!
One of the best youtube channel I have come across. Love your explanations.
Every weekend I like to watch ur new videos keep posting
What a clear and practical explanation, thank u sir!
The code example is quite comprehensive and useful.
Great thanks!
hi sir, hats of to you..... Thank you very much. very nice explanation. I read multiple article about map Vs flatMap, I could not understand but after watching your video I am very clear now. I can answer to interviewer very comfortably after watching this video.
Awesome thanks Atul
Sir ur explanation is very simple and understanding every time.. Please keep doing it 🙏👏👏
Bayya ...Extraordinary Explanation. I don't have words...
Thanks Krish 😊
Good. I read so many times flatMap is map+flattering, but didnt really understand what flattering is. Thanks
Excellent explanation in a very systematic way with good clear example.. Thank you
This si the real TeachingTalent Instructor
bhai best tutorial i have ever seen...love you.
Simple & Precise..
keep it up
How come I missed so useful channel.
Crystal clear explanation. Thanks for such a nice content.
Thanks buddy 😊
Thank you , Its was really crystal clear explanation .
Thank you java tech guru, helping lot to understand the key concepts
Jai hind
Thanks for the video. One to One and One to Many explanation was really really great.
Thanks..expecting more tutorials on java 8 + features. I would really appreciate if you would take a competitive programming challenge and show us how to use java 8 + features to solve it.
Sure we will do .
It would be really interesting to leverage Java 8 to solve cp questions.
Great job. One note, for those of use that our OCD kicks in easily it will not be easy to watch the code comments being 2 tabs behind the rest of the code (6:32)
What an explanation sir .. hats off
So concise and too the point.... Thanks a lot
Thanks a lot!
15 minutes and I got it very clear.
Thanks sir...this topic is very helpful for interview purpose
Always learning new concepts from here. Thank you. I am expecting an example of large project consist of multiple modules and one for authentication and authorisation.
Thanks Ranjan , Please checkout my microservice playlist
Excellent, finally understood. Thanks a TON.
Very clearly explained, this is what I was looking for. Thanks 👍
Thank you for your nice explanation
Thank you so much. Best way to explain properly. Jai hind Ji
Way of explanation is very good
GREAT EXPLAINATION ....Thanks SIR
Very good information, thank you very much
Thanks for the wonderful Explanation! Clear shot
Thanks u told in very simpler way easily understood 😀
Awesome+Simple explanation!! Thanks a ton ❤️
Nice and short explanation to the point
Thanks a lot for your efforts and putting this video.
Great, simple and easy explaining the stream👍🏾
Thank you, sir - really good that you provide code for reference ...
Great video. Hope to see all other Java8 related videos soon. 🙃😊
great job! the first one clearly explained flatMap() . thanks man!
btw, one suggestion, please use a runnable project structure when committing code to github. Your code is not well organized which is mismatching the package name and cannot be run out of the box.
Thanks KIM , yes you are correct I should runnable project structure .
very good explanation. I understood at one time
Really awesome 👍 please create more videos on java 8. Such real time experience.
Thank you brother. You made it easy to understand.
Thanks buddy
Talk less , code more .. I really appreciate your efforts. Great learning from your videos. Nice explanation.
Boss is back. I pray to god that I wish to work in your organisation where you work, so that i can learn daily new things. I know it is a dream. But i will be thankful to god and you if my dream fulfills. I am fan of you after my cinema hero Mega Star Chiranjeevi.
i am sure you are much much younger than me. God bless you ..take care..
Omg Raghu glad to hear this 😊 .
I wish you will love my content as always
@@Javatechie ofcourse Basant..i like your voice and the way you explain the concepts which is very important..
Thanks Raghu ☺️. Keep in touch
@@Javatechie Hi Basant, today i looked into your video and also in the internet again and got thought to my mind.
I solved the problem which i asked you in your previous video.
As Webflux does not return NULL values and hence i handled null pointer exception with Mono.Error() and SwithIfEmpty().
Here is the code snippet:
Flux productFlux = productRepository.findAll().switchIfEmpty(Mono.error(new GetProductException("Hey Raghu exception caught...")));
Thanks/God Bless you, take care and stay safe..
Simple and clear explanation thank you
Am exciting all the 1.8 features in a single video plz this will help us a lot
Hi buddy it's already there please follow this video
th-cam.com/video/ePJrt5-G8eM/w-d-xo.html
Superb 👌 explanation ✌️
You have got a new subscriber. That's all I can say. Great learning for me. 😊👍
Thank you Sir. Nicely explained.
Thank you sir. Very informative.
Thanks .. it's Awesome . but i hava one note : reduce the number of adds , only in this vedio it contains 3 or 4 adds .
again thanks for your effort
Awesome explanation sir, Great❤
Thanks for your wonderful explanation!!
You are my favorite techie bro!
Very clear explanation 🔥👌🏻
Very well explained thanks 👍👍
Thanks for making it look so simple.
Nice Bro! This is the clearest explanation ever :)
Thanks buddy 😊
Thanks for the nice explanation.
Helpful, thanks for the video.
flat·ter·ing
/ˈfladəriNG/
Learn to pronounce
adjective
(of a person or their remarks) full of praise and compliments.
"the article began with some flattering words about us"
You mean flattening. Good presentation all the same. Thank you
Yes I did wrong pronunciation here . Extremely sorry for this .
Very good explanation 😊
Very nice explanation
Thanks for clearing the point
beautiful explanation. thankyou.
Well explained. Thank u so much
A clear explanation
Sir , your video's give good insight one request to you please use speaker. ur voice is low or speak loudly. It will have good impact. Thanks
Thanks buddy I will try to make more loud going forward. For time being Please increase volume
Fan of Java techie
thanks for the great tutorial.. will really appreciate if you can show some complex flatmap operations with List of Maps etc.. it is tricky sometimes to work with HashMap in streams.
Okay i will do
very nicely explained . Great work !!
I want to many codes on net but your example has got me the logic so well that now I will never forget its use. Thanks man. You can check my coding videos too if you want.
Hi please share your channel name
@@Javatechie no channel,just I have uploaded few videos of technology. No professional channel.
Yes please share
@@Javatechie th-cam.com/video/Q4Q064e1jcE/w-d-xo.html
Well explained!! Very nice video!!!!!
thanks basant
short and crisp!
Very clear explanation
Superb tutorial
Awesome video sir ji
Thanks Java Techie 🙏🙏
Excellent explanation 🔥🔥
good explanation! Thank you!
Thanks basant 🙏
Thank you sir, You are Awsommmmmmmmm....