Optionals In Java - Simple Tutorial

  Рет қаралды 190,238

Coding with John

Coding with John

Жыл бұрын

Full tutorial on Optionals in Java!
Thanks to FlexiSpot for sponsoring! 🖥️ Get your coupon code for an extra $30 OFF through my link: bit.ly/3QPNGko
FlexiSpot Pro Plus Standing Desk E7
bit.ly/3xTvGNF (US site)
bit.ly/3OEL9aT (CAN site)
Join FlexiSpot Member Day during 29-30th June 2022! Up to $100 OFF! bit.ly/3u0akNa
#MyFlexiDesk #flexiblewfh
Complete Java course: codingwithjohn.thinkific.com/...
Optionals were added in Java 8, but can be a confusing thing to learn. This tutorial will walk through all of the aspects of Optionals in Java detail, then walk through step by step when and how to use optionals in your own code!
If you're confused by Optionals in Java, either just what they are and why they exist in general, or how to code to use them in Java, you're in the right place!
Learn or improve your Java by watching it being coded live!
Hi, I'm John! I'm a Lead Java Software Engineer and I've been in the programming industry for more than a decade. I love sharing what I've learned over the years in a way that's understandable for all levels of Java learners.
Let me know what else you'd like to see!
Links to any stuff in this description are affiliate links, so if you buy a product through those links I may earn a small commission.
📕 THE best book to learn Java, Effective Java by Joshua Bloch
amzn.to/36AfdUu
📕 One of my favorite programming books, Clean Code by Robert Martin
amzn.to/3GTPVhf
🎧 Or get the audio version of Clean Code for FREE here with an Audible free trial
www.audibletrial.com/johnclean...
🖥️Standing desk brand I use for recording (get a code for $30 off through this link!)
bit.ly/3QPNGko
📹Phone I use for recording:
amzn.to/3HepYJu
🎙️Microphone I use (classy, I know):
amzn.to/3AYGdbz
Donate with PayPal (Thank you so much!)
www.paypal.com/donate/?hosted...
☕Complete Java course:
codingwithjohn.thinkific.com/...
codingwithjohn.com

Пікірлер: 427
@stevenschelling8452
@stevenschelling8452 Жыл бұрын
This is the gold standard of coding tutorials, thanks for such well-structured info
@iamarnabpal
@iamarnabpal Жыл бұрын
Seriously... Pure GOLD!
@YatiAcharya
@YatiAcharya 10 ай бұрын
You know how I am certain this is the best Java channel? I have no interviews to crack, I have no exams to clear and I'm still here learning because it just is explained in such an interesting, problem-solution kinda way. Brilliant work, John!
@Amitjha406
@Amitjha406 6 ай бұрын
Agreed
@BryanChance
@BryanChance 5 ай бұрын
Yes, I second that. This is the best Java channel. :)
@nikamz6077
@nikamz6077 Жыл бұрын
My coding exam is in just about a month - and I would like to thank you, John! You have helped me so much. If I pass, thats because of you. Love your channel! Greetings from germany. :)
@nikamz6077
@nikamz6077 Жыл бұрын
Update: I passed. 😍💪🏻
@celeryman1650
@celeryman1650 Жыл бұрын
Congrats!!
@CodingWithJohn
@CodingWithJohn Жыл бұрын
Great to hear! Congrats!
@user-nu6vz9pt8g
@user-nu6vz9pt8g 9 ай бұрын
@@nikamz6077 Congrats!
@ItIsJan
@ItIsJan 9 ай бұрын
​@@nikamz6077gut gemacht!
@juanantoniosicardocontrera8390
@juanantoniosicardocontrera8390 3 ай бұрын
It's very difficult to find such well explained, well paced and easy to understand coding tutorials on youtube, thanks and congrats for having such good content.
@adrianfiedler3520
@adrianfiedler3520 Жыл бұрын
Always wondered what the true benefit of optionals vs null checks is. This really cleared things up for me!
@gulbalasalamov1367
@gulbalasalamov1367 Жыл бұрын
Love the cat example and box metaphor! :) 4:45
@LightningLion500
@LightningLion500 Жыл бұрын
I just started watching your channel and I love your calm and reassuring way of explaining complex coding aspects! It motivated me to work a little harder on my own projects, unlike the often condescending explainations of the teachers at my university. Thanks John!
@cloyyd2227
@cloyyd2227 Жыл бұрын
i just started my internship for the summer and the code they have us working with has a ton of optionals, which was something i had never heard of. You’re videos are truly always a highlight to my day and explain it so neatly and concisely, not to mention the timing! please keep doing what you do
@MariaBose-ky9jf
@MariaBose-ky9jf Жыл бұрын
I love your channel for the calm and precise manner you describe things with - and also the nerdy references ahah
@gerdsfargen6687
@gerdsfargen6687 Жыл бұрын
So good..guys, just keep coming back to John's channel. He explains everything with the greatest of ease.
@RsZ789
@RsZ789 Жыл бұрын
Great job, John. Can you please cover logging and best practices for it?
@chinmayrath8494
@chinmayrath8494 Жыл бұрын
please keep blessing us with such non trivial concepts. much love !!
@sg4644
@sg4644 8 ай бұрын
I've a exam on Java tomorrow and I've to say your videos on Java are probably the best on KZbin. Will be binge watching the your entire Java playlist tonight.
@christianolsson8644
@christianolsson8644 Жыл бұрын
What an excellent video! I have studied Java but not worked with it and now I try to polish my knowledge to get a job in Java. I want to thank you for your easy to understand and amazing videos that take up very important and interesting topics. You're an amazing teacher and you get excited to learn more to look at your videos :)
@midhunmadhu5305
@midhunmadhu5305 Жыл бұрын
I don't usually comment on any youtube videos. But here John, You are doing an excellent job describing topics in a simpler manner. Thank You.
@rlasc84
@rlasc84 Жыл бұрын
Nice solution for dealing with null exceptions. So much cleaner than use ifs to check the return value. Hopefully some day java implements de null safe operator like groovy or kotlin. Great video John!
@user-jz4iz2qh9u
@user-jz4iz2qh9u Жыл бұрын
Your channel is my go to for any Java related topic. Thank you! Could you please consider making some design patterns tutorials? 🙏🏻
@zaph8015
@zaph8015 Жыл бұрын
Null safety is one of the reasons I fell in love with Kotlin. It's caught me out so many times and helped me to think about where NPEs might be found even when working in other languages.
@petarJK
@petarJK Жыл бұрын
Excellent video! Very well explained. It's one thing to know something, totally different thing to be able to explain it well. Thanks!
@mohammedalbj4268
@mohammedalbj4268 10 ай бұрын
This is pure gold, thank you so much!
@MrLuMax5
@MrLuMax5 Жыл бұрын
Have been waiting for this for a long time, thank you!
@dinaadel1672
@dinaadel1672 Жыл бұрын
your videos are really useful and easy to understand.. and you are explaining lots of interview subjects.
@juvipana
@juvipana Жыл бұрын
This was awesome, you made me chuckle. Made it really easy to follow, thank you!
@miltonezeh5085
@miltonezeh5085 7 ай бұрын
You are the BEST on these streets.
@Fnaf-vh9cs
@Fnaf-vh9cs Жыл бұрын
this is something new definitely, IL look tomorrow into video and check some exercises. thanks John
@rikkarth_
@rikkarth_ 11 ай бұрын
Thank you, this video has helped me immensely.
@viswanathsairam5956
@viswanathsairam5956 Жыл бұрын
Optionals demystified with your video. Thanks a lot for this precise explanation
@j.franciscox3318
@j.franciscox3318 9 ай бұрын
Love that desk setup, could you do a video about your desk setup? And maybe other stuff as well, such as your favorite IDE, text editors etc.
@Anderzon1994
@Anderzon1994 Жыл бұрын
Thanks for sharing your knowledge! I enjoy watching your tutorials!
@sanjayranga2683
@sanjayranga2683 Жыл бұрын
The best possible explanation of Optional . You ve earned a subs and keep up.
@user-te9hf7qs1y
@user-te9hf7qs1y Жыл бұрын
Thank you for your excellent videos! Best explanation of these small java- things!
@ShermukhammadKarimov
@ShermukhammadKarimov 5 күн бұрын
thanks for the clear explanation
@ramkumar_balu
@ramkumar_balu Жыл бұрын
Perfect and standard video about the Optional.
@Ke5gggggel
@Ke5gggggel Жыл бұрын
Love your videos! Always looking if you made a video on the java subject I am looking for first before I watch a video of somebody else. Do a Tutorial about Streams please!
@emilywilson7835
@emilywilson7835 6 ай бұрын
This channel brings me so much joy, and taught me so much. Thanks!
@ahouzimohamed6387
@ahouzimohamed6387 Жыл бұрын
Hi John thank u for ur efforts , can u please do a tutoriel about the spring and spring boot it will be amazing by u
@Un_Fulano_
@Un_Fulano_ Жыл бұрын
It would have taken me hours to look for and understand this information by myself. Thanks John.
@isleschild
@isleschild 24 күн бұрын
thanks for the work, this was excellent.
@ReBufff
@ReBufff Жыл бұрын
Didn't even know what optionals were until now. Thanks!
@gabrielfono844
@gabrielfono844 11 ай бұрын
this is so amazing as backend engineer, I 100% agree thanks a lot
@magadiflo-dev
@magadiflo-dev Жыл бұрын
Excellent explanation, calmly, deliberately and well mastered the subject, thanks for sharing your knowledge, greetings from Peru 🇵🇪
@JoaoLima-pq1hm
@JoaoLima-pq1hm 8 ай бұрын
Precious content, thank you! Greetings from Brazil 😊
@chentang514
@chentang514 Жыл бұрын
Amazing tutorial. Very clear.
@TechOnScreen
@TechOnScreen Жыл бұрын
you just compiled all the facts about optional, thanks. can you also make a video on streams and lambdas and collections using them together to build business grade logical error-proof solutions..
@xtay2287
@xtay2287 Жыл бұрын
Didn't know about the map-method. Thanks :)
@liliabekuzinaensosense8987
@liliabekuzinaensosense8987 Жыл бұрын
You are just AMAZING! Please never stop! 💫
@pranaylonkar19
@pranaylonkar19 Жыл бұрын
Awesome video...👍 Now this concept is crystal clear. Please upload videos on streams, functional interface, method reference, and default method. Thanks...
@Ramison273
@Ramison273 Жыл бұрын
my god, you are the best. i am from brazil and i am learning a lot with you. i love java and i found your channel last month, i am watching all your videos, your english and your explanation is so easy to understand.. thank you 😁😁
@vamonosraza4361
@vamonosraza4361 Жыл бұрын
I am So grateful for your videos!
@LutfarRahmanMilu
@LutfarRahmanMilu 10 ай бұрын
Absolutely brilliant teaching style.
@mohammadsadeghsheikhzahedi3682
@mohammadsadeghsheikhzahedi3682 9 ай бұрын
Great job 🙏
@gamingislove3030
@gamingislove3030 Жыл бұрын
Best video i ever saw on Optional.🎉🎉
@BrunoAraujo14
@BrunoAraujo14 2 ай бұрын
Thanks for this class, Schrodinger! 4:35
@iot_enthusiast
@iot_enthusiast Жыл бұрын
Wondering if you are planning to create Spring Boot content anytime soon :) After watching several videos in your channel, I believe that with that highly intuitive style of explaining subtle as well as complex, hard to understand concepts, the new content will attract a lot of views. Happy to be a subscriber :)
@xmaxxxwellx
@xmaxxxwellx Жыл бұрын
Hi John! It's fantastic) I'm really appreciate it. The video is great! Thanks a lot :)
@rezahajivand7498
@rezahajivand7498 9 ай бұрын
Hello mr jhon . Thanks for your teaching video 🎉🎉🎉
@boldschool6308
@boldschool6308 Жыл бұрын
I definitely learned something! Thanks
@ginasomara267
@ginasomara267 Жыл бұрын
Bro life saver. Your videos are amazing.
@yashaswipandey7923
@yashaswipandey7923 Жыл бұрын
Thanks man, i needed that.
@asherkhan2656
@asherkhan2656 10 ай бұрын
Great explanation John
@Softrough1989
@Softrough1989 Жыл бұрын
Very good explanation and I loved the cat and the box. Thanks
@SUMITYADAV-cy9hf
@SUMITYADAV-cy9hf 2 ай бұрын
hey John !!! amazing work requesting you to create a spring framework course as well .
@gopalkannan4934
@gopalkannan4934 Жыл бұрын
I love your channel. Thank you so much
@mohamedlegtibi802
@mohamedlegtibi802 Жыл бұрын
Best teacher so far. Greetings from Morocco 🇲🇦
@azam11250
@azam11250 2 ай бұрын
great explaination sir. really liked ur videos and learned a lot. Thanks sir
@eduardoprado8055
@eduardoprado8055 Жыл бұрын
Awesome explanation!
@shakilahmed4647
@shakilahmed4647 Жыл бұрын
Before this I used to think optional is a mysterious box in Java. Thanks for the video
@reynerb3918
@reynerb3918 2 ай бұрын
Thank you for the video, this is great content...
@cosmoatlas2435
@cosmoatlas2435 Жыл бұрын
wish I had you the sophomore year of college. Great work!
@muhammedemad1155
@muhammedemad1155 Жыл бұрын
Great tutorial , thank you
@jaylawlmc1915
@jaylawlmc1915 Жыл бұрын
THANK YOU SO MUCH for actually explaining when are where optionals are actually useful as opposed to using a return annotated with "@Nullable". I am lucky to have understood this topic before watching your video, but before i got to that point i was *severely struggling* to get behind why i would use Optional instead of null in the first place. That is due to many tutorials on optionals just leaving things at "it's a container where a value may or may not be present" but not going as far as you did. I'm absolutely certain this video of yours will help tons of people!
@pauldhartley
@pauldhartley Жыл бұрын
I must confess to still being confused at the usefulness of optionals, though the video explains admirably some of the characteristics.
@jaylawlmc1915
@jaylawlmc1915 Жыл бұрын
@@pauldhartley cleaner and more functional code. Try working with streams for example. You cannot unlock the full power of streams using null checks
@jaylawlmc1915
@jaylawlmc1915 Жыл бұрын
@@pauldhartley I point out functionality because you cannot much with a null value, other than check it and pass it. Optionals on the other hand, are integrated into javas core functionality. You can do tons of things with them just with what java provides. That doesn't even take into account what you or others may code for it
@jagger6277
@jagger6277 Жыл бұрын
THANK YOU!!!
@whitneybrown1715
@whitneybrown1715 Жыл бұрын
Awesome tutorial!
@timmelis4872
@timmelis4872 Жыл бұрын
Another very well explained video ...
@shepherdej1010
@shepherdej1010 Жыл бұрын
Hey John, first off, fantastic Video and well explained. Second, would you be able to do a video on the Java Garbage Collector and ways to utilize it?
@ultimatehuzefa
@ultimatehuzefa Жыл бұрын
Best Java Tutor!!
@arcane3327
@arcane3327 Жыл бұрын
The explanation with your cat was really great. Thanks for the good tutorial!
@siegfriedkurz8753
@siegfriedkurz8753 Жыл бұрын
Impressively explained.
@saiprakash5501
@saiprakash5501 Жыл бұрын
Hi John, Nice content!...Keep up the good work🤝
@RotatingBuffalo
@RotatingBuffalo Жыл бұрын
This is an example of a monad, in case anyone here has heard of monads but doesn't know what they are useful for yet. They generally provide a "Wrapper type" that you can use to chain operations safely on, without having to do intermediate work between every function/method.
@d2k2
@d2k2 4 ай бұрын
Thank you!
@nishiths9228
@nishiths9228 Жыл бұрын
I always check out your videos cause it’s very easy to understand even the difficult concepts because of easy to understand explanations. I would love to buy the keyboard that you are using , which one is that :) Thanks in advance .
@dsmohammadaslam9527
@dsmohammadaslam9527 3 ай бұрын
your are just extraordinary sir , thank you sir please make video on java date and time
@victor__425
@victor__425 Жыл бұрын
Awesome! The society demands explaining all java features basing on this cute cat
@tostanco1117
@tostanco1117 Жыл бұрын
I do recognize the way you speak so clearly.
@dhilip77
@dhilip77 Жыл бұрын
Your explanation are really simple, when could I expect spring boot
@sebon11
@sebon11 Жыл бұрын
Great video as always
@alinesinclaire2854
@alinesinclaire2854 11 ай бұрын
epic explanation with the cat in the box it was so funny!
@svalyavasvalyava9867
@svalyavasvalyava9867 Жыл бұрын
thank you infinitely!!!
@VivekSharma-zb6no
@VivekSharma-zb6no Жыл бұрын
Nice explanation 😊
@philbowden3894
@philbowden3894 Жыл бұрын
Once again....excellent video.
@aurojitbasak3249
@aurojitbasak3249 Жыл бұрын
Great 👍👍👍 I was waiting for your video. Thanks. Love from India. ❤️❤️
@xugefu
@xugefu Жыл бұрын
Thanks!
@nate6199
@nate6199 Жыл бұрын
Would you be able to do a video on using serializable for persistent data?
@vijaydhanakodi5591
@vijaydhanakodi5591 Жыл бұрын
you should really teach design patterns. one of the best tutor in the universe.
@ashadahmad651
@ashadahmad651 Жыл бұрын
I loved your explanation John, the way you explained was amazing, soothing and very clear. Especially loved the part where you mentioned how exactly a Optional is intended to be used, amazing content. Any chance you make courses on Springboot, Microservices etc please do upload them if you do or provide us a link to the course. Thanks once again.
@Manish-ly7iw
@Manish-ly7iw Жыл бұрын
his name is john though
@ashadahmad651
@ashadahmad651 Жыл бұрын
@@Manish-ly7iw ohhh shit
@Anon-jz7iw
@Anon-jz7iw 2 ай бұрын
holy crap i was getting everything but the end just screwed with my head more, would definitely try to apply this in my project to learn it more
@akshaysilgari2097
@akshaysilgari2097 Жыл бұрын
Very nice explain bro.....
@kareem7236
@kareem7236 Жыл бұрын
thank you soo much
@mdk1983
@mdk1983 3 ай бұрын
A 6'5'' John saying "OR ELSE" to the face is quite a threat 😀 Wonderful and interesting tutorial as always. You're the best John!
Lambda Expressions in Java - Full Simple Tutorial
13:05
Coding with John
Рет қаралды 681 М.
Java Reflection Explained - bɘniɒlqxƎ noiɟɔɘlʇɘЯ ɒvɒᒐ
20:07
Coding with John
Рет қаралды 165 М.
McDonald’s MCNUGGET PURSE?! #shorts
00:11
Lauren Godwin
Рет қаралды 28 МЛН
LA FINE 😂😂😂 @arnaldomangini
00:26
Giuseppe Barbuto
Рет қаралды 21 МЛН
New Java Version 22 - The 3 Best New Features You'll ACTUALLY Use
13:15
Coding with John
Рет қаралды 47 М.
Java 8 Streams | Optional Usage and Best Practices | JavaTechie
22:22
Set and HashSet in Java - Full Tutorial
20:43
Coding with John
Рет қаралды 183 М.
How To Call a REST API In Java - Simple Tutorial
29:14
Coding with John
Рет қаралды 246 М.
Generics In Java - Full Simple Tutorial
17:34
Coding with John
Рет қаралды 997 М.
Java 8 STREAMS Tutorial
18:10
Oggi AI - Artificial Intelligence Today
Рет қаралды 723 М.
Java Custom Exceptions Tutorial - It's Way Easier Than You Think
14:29
Coding with John
Рет қаралды 139 М.
McDonald’s MCNUGGET PURSE?! #shorts
00:11
Lauren Godwin
Рет қаралды 28 МЛН