This is the gold standard of coding tutorials, thanks for such well-structured info
@iamarnabpal Жыл бұрын
Seriously... Pure GOLD!
@YatiAcharya Жыл бұрын
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 Жыл бұрын
Agreed
@BryanChance Жыл бұрын
Yes, I second that. This is the best Java channel. :)
@nikamz60772 жыл бұрын
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. :)
@nikamz60772 жыл бұрын
Update: I passed. 😍💪🏻
@celeryman16502 жыл бұрын
Congrats!!
@CodingWithJohn2 жыл бұрын
Great to hear! Congrats!
@MarynaSapiton Жыл бұрын
@@nikamz6077 Congrats!
@ItIsJan Жыл бұрын
@@nikamz6077gut gemacht!
@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.
@whiterabbit93105 ай бұрын
Dude, I can say for sure that your way of explaining is the best I've seen on KZbin ever. That's considering that I'm not a native speaker. Thank you a lot.
@Cloydz2 жыл бұрын
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
@wellingtonaraujo541811 күн бұрын
after some years i still get myself drinking coffee and watching your videos, awesome content
@LightningLion5002 жыл бұрын
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!
@midhunmadhu53052 жыл бұрын
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.
@sg4644 Жыл бұрын
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.
@gulbalasalamov13672 жыл бұрын
Love the cat example and box metaphor! :) 4:45
@jpp8554 күн бұрын
Reality: Optional is just workaround of a big and unsolved problem in Java language.
@jaylawlmc19152 жыл бұрын
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!
@pauldhartley2 жыл бұрын
I must confess to still being confused at the usefulness of optionals, though the video explains admirably some of the characteristics.
@jaylawlmc19152 жыл бұрын
@@pauldhartley cleaner and more functional code. Try working with streams for example. You cannot unlock the full power of streams using null checks
@jaylawlmc19152 жыл бұрын
@@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
@mayankgupta9277 Жыл бұрын
Can't resist writing a review, I am preparing for a job as a developer and chose Java as my technology, I have been learning since 4 months now, I was completely devastated and lost few days back as I am not getting any calls for the interviews, luckily discovered your channel and since then I have been going through all the concepts again from your videos, it's just making me so much more confident and stronger, your energy is just pure GOLD! All the topics have been explained crisply. Hope I'll soon land a good offer! Lots of love from India! ❤❤❤❤
@mayankgupta9277 Жыл бұрын
Late Update: I am thrilled to announce that one month ago, I joined as a Java Developer in one of the best companies out there. Everything is perfect; my new job fulfills everything I have been looking for, and it feels like a dream 😍. Many thanks to John for his positive energy, knowledge, down-to-earth attitude, and all the help during my journey. I owe this to you John. Thanks to God and everyone for believing in me.
@juanantoniosicardocontrera839010 ай бұрын
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.
@RsZ7892 жыл бұрын
Great job, John. Can you please cover logging and best practices for it?
@RotatingBuffalo2 жыл бұрын
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.
@AlamMahmood10 ай бұрын
As a kinesthetic learner I would like to thank you for bringing the actual cat for this videos which was Optional
@gamingislove3030 Жыл бұрын
Best video i ever saw on Optional.🎉🎉
@hashcodehub67172 ай бұрын
love all of your content , it is clear precise and easy to consume i was thinking that it was really really tough but now i am very much comfortable with optionals
@pastasempa2 жыл бұрын
Hi John, I had an interview for SDE 3 at Walmart today, and I literally was able to answer everything along with proper Implementation, knocked it out of the park! Your tutorials are very brain-friendly, which is rarity nowadays :)
@CodingWithJohn2 жыл бұрын
Awesome, thanks for sharing! Hope you get a great offer!
@satioOeinas Жыл бұрын
did you get the offer bro?
@CodingWithJohn Жыл бұрын
rip @pastasempa
@pastasempa Жыл бұрын
@@CodingWithJohnl got an amazing offer and bought a nice cruiser motorcycle with that paycheck!!
@CodingWithJohn Жыл бұрын
Hey that's amazing, congratulations!!
@gerdsfargen66872 жыл бұрын
So good..guys, just keep coming back to John's channel. He explains everything with the greatest of ease.
@RealNikolaus Жыл бұрын
Always wondered what the true benefit of optionals vs null checks is. This really cleared things up for me!
@viswanathsairam59562 жыл бұрын
Optionals demystified with your video. Thanks a lot for this precise explanation
@christianolsson86442 жыл бұрын
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 :)
@mohamedlegtibi802 Жыл бұрын
Best teacher so far. Greetings from Morocco 🇲🇦
@MariaBose-ky9jf2 жыл бұрын
I love your channel for the calm and precise manner you describe things with - and also the nerdy references ahah
@jaswdrTheDev5 ай бұрын
Optionals are extremely useful and explicitly and semantically tell the caller to deal with nulls 😊
@ramkumar_balu Жыл бұрын
Perfect and standard video about the Optional.
@g_r_x_v Жыл бұрын
It would have taken me hours to look for and understand this information by myself. Thanks John.
@Ramison2732 жыл бұрын
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 😁😁
@gabrielfono844 Жыл бұрын
this is so amazing as backend engineer, I 100% agree thanks a lot
@sanjayranga2683 Жыл бұрын
The best possible explanation of Optional . You ve earned a subs and keep up.
@ReBufff2 жыл бұрын
Didn't even know what optionals were until now. Thanks!
@tostanco11172 жыл бұрын
I do recognize the way you speak so clearly.
@alinesinclaire2854 Жыл бұрын
epic explanation with the cat in the box it was so funny!
@shakilahmed46472 жыл бұрын
Before this I used to think optional is a mysterious box in Java. Thanks for the video
@miltonezeh5085 Жыл бұрын
You are the BEST on these streets.
@mdk19839 ай бұрын
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!
@LutfarRahmanMilu Жыл бұрын
Absolutely brilliant teaching style.
@mohammedalbj4268 Жыл бұрын
This is pure gold, thank you so much!
@pebble62482 жыл бұрын
Coding with John deserves more attention.
@CodingWithJohn2 жыл бұрын
Feel free to share! And thanks for watching!
@victor__4252 жыл бұрын
Awesome! The society demands explaining all java features basing on this cute cat
@emilywilson7835 Жыл бұрын
This channel brings me so much joy, and taught me so much. Thanks!
@vijaydhanakodi55912 жыл бұрын
you should really teach design patterns. one of the best tutor in the universe.
8 ай бұрын
Thanks for this class, Schrodinger! 4:35
@MusicMan1212 жыл бұрын
Cats definitely love playing with/in Optionals
@rlasc842 жыл бұрын
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!
@aeraf3 ай бұрын
Thank you for explaining the concept
@personalaccount1515 Жыл бұрын
Thanks! Direct to the point, it worth all 16 minutes. If I could give 100 likes I will ask why I can't give 1,000
@chinmayrath84942 жыл бұрын
please keep blessing us with such non trivial concepts. much love !!
@Amitkumar-dv1kk2 жыл бұрын
The alternative is to just add a method signature that throws a null pointer exception, this will convey the message as well.
@dinaadel16722 жыл бұрын
your videos are really useful and easy to understand.. and you are explaining lots of interview subjects.
@magadiflo-dev Жыл бұрын
Excellent explanation, calmly, deliberately and well mastered the subject, thanks for sharing your knowledge, greetings from Peru 🇵🇪
@liliabekuzinaensosense89872 жыл бұрын
You are just AMAZING! Please never stop! 💫
@Fnaf-vh9cs2 жыл бұрын
this is something new definitely, IL look tomorrow into video and check some exercises. thanks John
@yassineabidarIt2 жыл бұрын
Great content thank you. Just for Optional the right use case was the use in the public method rather than the private method.
@CodingWithJohn2 жыл бұрын
Yep, generally for a private method it's not really a big deal.
@ShermukhammadKarimov7 ай бұрын
thanks for the clear explanation
@ahouzimohamed63872 жыл бұрын
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
@muhammetalimutlu674810 ай бұрын
Why is this guy so sympathetic
@pradheeshkumar-v4p23 күн бұрын
Hi John !! Your Java tutorials are compendious , please post videos specific to java development like building REST API , Spring Data JPA , Hibernate , Spring MVC etc.. That would be of a great help. Thank You !!
@OmarMendozaKS2 жыл бұрын
Best "Real life" explanation ever, haha, the cat deserves credit for it!!
@CodingWithJohn2 жыл бұрын
Fred was a good sport. It didn't turn out exactly like I had imagined if he fully cooperated, but worked well enough.
@juvipana Жыл бұрын
This was awesome, you made me chuckle. Made it really easy to follow, thank you!
@rikkarth_ Жыл бұрын
Thank you, this video has helped me immensely.
@Fanchiotti2 жыл бұрын
Couple of questions: 1) Can you pass a Runnable to the orElse() method? 2) Can Optionals return lists or vectors?
@wikkkkid2 жыл бұрын
You can’t pass a Runnable to orElse unless your Optional is a wrapper for a Runnable type (which would be strange..) Optional is defined as Optional and so can return whatever you define T as, for a list of Person objects you would use Optional however this is a bad practice as in the case of collections if there is no list (I.e no records were found in a data store) you should return an empty instance of that collection. The orElse is defined as “T orElse()” this is always executed even when the Optional is not empty, I.e .orElse(new Person()) will always create the person instance (but if the optional is empty then this will just be disposed of and the GC will do it’s work on the next GC run.. if you want to perform logic if your optional is empty you should use orElseGet which is defined as T orElseGet(Supplier), the supplier is only executed if the Optional is empty. Hope this helps :)
@ginasomara2672 жыл бұрын
Bro life saver. Your videos are amazing.
@cosmoatlas24352 жыл бұрын
wish I had you the sophomore year of college. Great work!
@lolloBriggi Жыл бұрын
Sometimes, I feel like programmers always need to overcomplicate things and come up with Schrödinger's cat solutions. I'll stick to 'if not null else'. Verbosity is better than Schrödinger's cat solutions to me.
@siddharthgollapudi619510 ай бұрын
loved that subtle Schrodinger's cat reference
@LeandroOliveira-kn9qx Жыл бұрын
The best is the final .. advice where to use, generally in return of funciona, not every where creating a mess.
@vamonosraza43612 жыл бұрын
I am So grateful for your videos!
@MrLuMax52 жыл бұрын
Have been waiting for this for a long time, thank you!
@pliegosevilla2 жыл бұрын
You remind me of those super cool, good and cute uni teachers everybody loves. Your videos are so fresh and spot on. I really like them, so thanks!!!!
@Iceman-gm1fu2 жыл бұрын
thanks for the video. I liked the cat object being used since cats like boxes. to me, it sounds like optionals are used as a communiation device to say something may or may not be there. really drive home the idea that it might be null. if I could, I think I would rename the class to Maybe: Maybe maybeCatExists = findCatByName("Fred"); the next question that I want to ask is "What are actual use cases of this?" You have me thinking. Checking the database for a record is a great example. I am thinking about using a jdbc bridge connecting java to sql. Thinking of right/left join on two or more tables where there won't be an exact match one very row. Maybe maybeRecordExists = findRecordByName
@redcrafterlppa3032 жыл бұрын
We probably get a second optional class in some future release of java. Since there are some huge performance improvements planned for the near future especially effecting optional. And then to keep compatibility they might add a similar type with better performance. Like they did with Vector and ArrayList.
@chentang5142 жыл бұрын
Amazing tutorial. Very clear.
@j.franciscox3318 Жыл бұрын
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.
@TechOnScreen2 жыл бұрын
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..
@neolin.99 Жыл бұрын
ah, a classic "we do not know if the cat is null or not null until we open the box, so until then, it is simultaneously null and not null"
@siegfriedkurz87532 жыл бұрын
Impressively explained.
@ultimatehuzefa2 жыл бұрын
Best Java Tutor!!
@petarJK2 жыл бұрын
Excellent video! Very well explained. It's one thing to know something, totally different thing to be able to explain it well. Thanks!
@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!
@arcane33272 жыл бұрын
The explanation with your cat was really great. Thanks for the good tutorial!
@JoaoLima-pq1hm Жыл бұрын
Precious content, thank you! Greetings from Brazil 😊
@xtay22872 жыл бұрын
Didn't know about the map-method. Thanks :)
@Anderzon19942 жыл бұрын
Thanks for sharing your knowledge! I enjoy watching your tutorials!
@MBerg-qq6gf8 ай бұрын
At 10:50 instead of demonstrating orElse with an "unknown cat" I would have used something like _string catDisplayValue = optionalCat.orElse("");_ because the whole point is to skip the "fake cat" (whether null, empty or unknown) and use directly the fallback value that needs to be used in the println when there's no cat! Please note that I suggested *pseudo code* -- my suggestion is not entirely syntactically correct (I come from c# and I don't know the Java equivalent to C#'s question mark yet)
@flytoinfinityvivi7 ай бұрын
How to know if a youtube video is successful and worth watching? When you even enjoy watching the ads inserted into the videos lol love it
@dhilip772 жыл бұрын
Your explanation are really simple, when could I expect spring boot
@asherkhan2656 Жыл бұрын
Great explanation John
@dennisvanmierlo2 жыл бұрын
A cat in a box. It’s the perfect combo👌 Thank you for this great tutorial!
@RishiRajxtrim Жыл бұрын
thanks
@biswarana4491 Жыл бұрын
Cat be like : things i need to comply with for some food..
@BaalZepar2 жыл бұрын
I would've loved a secondary parameter to the .of method that asks for a default of the type contained in the optional, and a method orDefault on the optional, that would basically act like the get but return the default in case of an empty optional. This would allow for a null object pattern to be implemented from the start of the optional and for the users of the returned optional to decide if they care if the optional is empty or to go forward with the default provided by the creator method of the optional. It will also make sense, because who know better what a suitable default of the optional is, if not the creator of the returned value, and if the users of the value want they can always go with orElse, orElseGet, etc if they need a different default behavior on empty optionals. With the way it is now, everywhere you will get an optional as a return type you will have to interact with it in some way, granted, better than an if statement everywhere but can be better imo.
@isleschild7 ай бұрын
thanks for the work, this was excellent.
@abiz5042 жыл бұрын
No cats were harmed during making of this tutorial :D You forgot to add that! Good tutorial loved it :)
@CodingWithJohn2 жыл бұрын
Yeah, Fred is a trooper
@Softrough19892 жыл бұрын
Very good explanation and I loved the cat and the box. Thanks
@Ahmad_Al-Deeb7 ай бұрын
"As a side note, if you know for sure, that the thing that you want to put into this optional is not NULL, then you can instead just use optional dot of" 6:06 Well, it sounds useless in this case, since the reason we used it was because of null case, right?
@elTripaSeca2 жыл бұрын
tutorial begin 1:35
@rezahajivand7498 Жыл бұрын
Hello mr jhon . Thanks for your teaching video 🎉🎉🎉
@azam112509 ай бұрын
great explaination sir. really liked ur videos and learned a lot. Thanks sir