Optionals In Java - Simple Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 18 พ.ย. 2024

ความคิดเห็น • 450

  • @stevenschelling8452
    @stevenschelling8452 2 ปีที่แล้ว +203

    This is the gold standard of coding tutorials, thanks for such well-structured info

    • @iamarnabpal
      @iamarnabpal ปีที่แล้ว +3

      Seriously... Pure GOLD!

  • @YatiAcharya
    @YatiAcharya ปีที่แล้ว +52

    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 ปีที่แล้ว

      Agreed

    • @BryanChance
      @BryanChance ปีที่แล้ว +2

      Yes, I second that. This is the best Java channel. :)

  • @nikamz6077
    @nikamz6077 2 ปีที่แล้ว +116

    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 2 ปีที่แล้ว +61

      Update: I passed. 😍💪🏻

    • @celeryman1650
      @celeryman1650 2 ปีที่แล้ว +4

      Congrats!!

    • @CodingWithJohn
      @CodingWithJohn  2 ปีที่แล้ว +13

      Great to hear! Congrats!

    • @MarynaSapiton
      @MarynaSapiton ปีที่แล้ว +1

      @@nikamz6077 Congrats!

    • @ItIsJan
      @ItIsJan ปีที่แล้ว +1

      ​@@nikamz6077gut gemacht!

  • @gulbalasalamov1367
    @gulbalasalamov1367 2 ปีที่แล้ว +8

    Love the cat example and box metaphor! :) 4:45

  • @Cloydz
    @Cloydz 2 ปีที่แล้ว +12

    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

  • @LightningLion500
    @LightningLion500 2 ปีที่แล้ว +22

    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!

  • @whiterabbit9310
    @whiterabbit9310 5 หลายเดือนก่อน +1

    Dude, I can say for sure that your way of explaining is the best I've seen on TH-cam ever. That's considering that I'm not a native speaker. Thank you a lot.

  • @RsZ789
    @RsZ789 2 ปีที่แล้ว +26

    Great job, John. Can you please cover logging and best practices for it?

  • @zaph8015
    @zaph8015 ปีที่แล้ว +6

    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.

  • @midhunmadhu5305
    @midhunmadhu5305 2 ปีที่แล้ว +5

    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.

  • @wellingtonaraujo5418
    @wellingtonaraujo5418 3 วันที่ผ่านมา

    after some years i still get myself drinking coffee and watching your videos, awesome content

  • @jaylawlmc1915
    @jaylawlmc1915 2 ปีที่แล้ว +10

    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 2 ปีที่แล้ว +2

      I must confess to still being confused at the usefulness of optionals, though the video explains admirably some of the characteristics.

    • @jaylawlmc1915
      @jaylawlmc1915 2 ปีที่แล้ว +1

      @@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 2 ปีที่แล้ว +1

      @@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

  • @juanantoniosicardocontrera8390
    @juanantoniosicardocontrera8390 10 หลายเดือนก่อน

    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.

  • @sg4644
    @sg4644 ปีที่แล้ว

    I've a exam on Java tomorrow and I've to say your videos on Java are probably the best on TH-cam. Will be binge watching the your entire Java playlist tonight.

  • @hashcodehub6717
    @hashcodehub6717 หลายเดือนก่อน

    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

  • @mohamedlegtibi802
    @mohamedlegtibi802 ปีที่แล้ว

    Best teacher so far. Greetings from Morocco 🇲🇦

  • @ramkumar_balu
    @ramkumar_balu ปีที่แล้ว

    Perfect and standard video about the Optional.

  • @viswanathsairam5956
    @viswanathsairam5956 2 ปีที่แล้ว +1

    Optionals demystified with your video. Thanks a lot for this precise explanation

  • @gamingislove3030
    @gamingislove3030 ปีที่แล้ว +1

    Best video i ever saw on Optional.🎉🎉

  • @sanjayranga2683
    @sanjayranga2683 ปีที่แล้ว

    The best possible explanation of Optional . You ve earned a subs and keep up.

  • @MariaBose-ky9jf
    @MariaBose-ky9jf ปีที่แล้ว

    I love your channel for the calm and precise manner you describe things with - and also the nerdy references ahah

  • @aeraf
    @aeraf 2 หลายเดือนก่อน

    Thank you for explaining the concept

  • @LutfarRahmanMilu
    @LutfarRahmanMilu ปีที่แล้ว

    Absolutely brilliant teaching style.

  • @g_r_x_v
    @g_r_x_v ปีที่แล้ว +1

    It would have taken me hours to look for and understand this information by myself. Thanks John.

  •  8 หลายเดือนก่อน

    Thanks for this class, Schrodinger!
    4:35

  • @mayankgupta9277
    @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
      @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.

  • @gerdsfargen6687
    @gerdsfargen6687 2 ปีที่แล้ว

    So good..guys, just keep coming back to John's channel. He explains everything with the greatest of ease.

  • @mohammedalbj4268
    @mohammedalbj4268 ปีที่แล้ว

    This is pure gold, thank you so much!

  • @RealNikolaus
    @RealNikolaus ปีที่แล้ว +1

    Always wondered what the true benefit of optionals vs null checks is. This really cleared things up for me!

  • @emilywilson7835
    @emilywilson7835 ปีที่แล้ว

    This channel brings me so much joy, and taught me so much. Thanks!

  • @ReBufff
    @ReBufff 2 ปีที่แล้ว

    Didn't even know what optionals were until now. Thanks!

  • @gabrielfono844
    @gabrielfono844 ปีที่แล้ว

    this is so amazing
    as backend engineer, I 100% agree
    thanks a lot

  • @pastasempa
    @pastasempa 2 ปีที่แล้ว +2

    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 :)

    • @CodingWithJohn
      @CodingWithJohn  2 ปีที่แล้ว +2

      Awesome, thanks for sharing! Hope you get a great offer!

    • @satioOeinas
      @satioOeinas ปีที่แล้ว

      did you get the offer bro?

    • @CodingWithJohn
      @CodingWithJohn  ปีที่แล้ว

      rip @pastasempa

    • @pastasempa
      @pastasempa ปีที่แล้ว +1

      @@CodingWithJohnl got an amazing offer and bought a nice cruiser motorcycle with that paycheck!!

    • @CodingWithJohn
      @CodingWithJohn  ปีที่แล้ว +1

      Hey that's amazing, congratulations!!

  • @christianolsson8644
    @christianolsson8644 2 ปีที่แล้ว +1

    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 :)

  • @j.franciscox3318
    @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.

  • @ahouzimohamed6387
    @ahouzimohamed6387 2 ปีที่แล้ว +4

    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

  • @miltonezeh5085
    @miltonezeh5085 ปีที่แล้ว

    You are the BEST on these streets.

  • @juvipana
    @juvipana ปีที่แล้ว

    This was awesome, you made me chuckle. Made it really easy to follow, thank you!

  • @liliabekuzinaensosense8987
    @liliabekuzinaensosense8987 2 ปีที่แล้ว

    You are just AMAZING! Please never stop! 💫

  • @cosmoatlas2435
    @cosmoatlas2435 2 ปีที่แล้ว

    wish I had you the sophomore year of college. Great work!

  • @victor__425
    @victor__425 2 ปีที่แล้ว

    Awesome! The society demands explaining all java features basing on this cute cat

  • @RotatingBuffalo
    @RotatingBuffalo 2 ปีที่แล้ว +1

    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.

  • @Softrough1989
    @Softrough1989 2 ปีที่แล้ว

    Very good explanation and I loved the cat and the box. Thanks

  • @ShermukhammadKarimov
    @ShermukhammadKarimov 6 หลายเดือนก่อน

    thanks for the clear explanation

  • @xtay2287
    @xtay2287 2 ปีที่แล้ว

    Didn't know about the map-method. Thanks :)

  • @rikkarth_
    @rikkarth_ ปีที่แล้ว

    Thank you, this video has helped me immensely.

  • @pradheeshkumar-v4p
    @pradheeshkumar-v4p 15 วันที่ผ่านมา

    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 !!

  • @tostanco1117
    @tostanco1117 2 ปีที่แล้ว

    I do recognize the way you speak so clearly.

  • @ginasomara267
    @ginasomara267 2 ปีที่แล้ว

    Bro life saver. Your videos are amazing.

  • @Fnaf-vh9cs
    @Fnaf-vh9cs 2 ปีที่แล้ว

    this is something new definitely, IL look tomorrow into video and check some exercises. thanks John

  • @AlamMahmood
    @AlamMahmood 10 หลายเดือนก่อน

    As a kinesthetic learner I would like to thank you for bringing the actual cat for this videos which was Optional

  • @chentang514
    @chentang514 ปีที่แล้ว

    Amazing tutorial. Very clear.

  • @magadiflo-dev
    @magadiflo-dev ปีที่แล้ว

    Excellent explanation, calmly, deliberately and well mastered the subject, thanks for sharing your knowledge, greetings from Peru 🇵🇪

  • @alinesinclaire2854
    @alinesinclaire2854 ปีที่แล้ว +2

    epic explanation with the cat in the box it was so funny!

  • @asherkhan2656
    @asherkhan2656 ปีที่แล้ว

    Great explanation John

  • @MusicMan121
    @MusicMan121 2 ปีที่แล้ว +1

    Cats definitely love playing with/in Optionals

  • @jaswdrTheDev
    @jaswdrTheDev 5 หลายเดือนก่อน

    Optionals are extremely useful and explicitly and semantically tell the caller to deal with nulls 😊

  • @chinmayrath8494
    @chinmayrath8494 2 ปีที่แล้ว

    please keep blessing us with such non trivial concepts. much love !!

  • @rlasc84
    @rlasc84 2 ปีที่แล้ว +2

    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!

  • @neolin.99
    @neolin.99 ปีที่แล้ว +1

    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"

  • @Ramison273
    @Ramison273 2 ปีที่แล้ว

    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 😁😁

  • @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!

  • @dinaadel1672
    @dinaadel1672 2 ปีที่แล้ว

    your videos are really useful and easy to understand.. and you are explaining lots of interview subjects.

  • @JoaoLima-pq1hm
    @JoaoLima-pq1hm ปีที่แล้ว

    Precious content, thank you! Greetings from Brazil 😊

  • @dhilip77
    @dhilip77 2 ปีที่แล้ว

    Your explanation are really simple, when could I expect spring boot

  • @arcane3327
    @arcane3327 2 ปีที่แล้ว

    The explanation with your cat was really great. Thanks for the good tutorial!

  • @rezahajivand7498
    @rezahajivand7498 ปีที่แล้ว

    Hello mr jhon .
    Thanks for your teaching video 🎉🎉🎉

  • @shakilahmed4647
    @shakilahmed4647 2 ปีที่แล้ว

    Before this I used to think optional is a mysterious box in Java. Thanks for the video

  • @siegfriedkurz8753
    @siegfriedkurz8753 2 ปีที่แล้ว

    Impressively explained.

  • @pebble6248
    @pebble6248 2 ปีที่แล้ว

    Coding with John deserves more attention.

    • @CodingWithJohn
      @CodingWithJohn  2 ปีที่แล้ว +1

      Feel free to share! And thanks for watching!

  • @siddharthgollapudi6195
    @siddharthgollapudi6195 9 หลายเดือนก่อน

    loved that subtle Schrodinger's cat reference

  • @vijaydhanakodi5591
    @vijaydhanakodi5591 2 ปีที่แล้ว

    you should really teach design patterns. one of the best tutor in the universe.

  • @MrLuMax5
    @MrLuMax5 2 ปีที่แล้ว

    Have been waiting for this for a long time, thank you!

  • @mdk1983
    @mdk1983 9 หลายเดือนก่อน

    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!

  • @boldschool6308
    @boldschool6308 ปีที่แล้ว

    I definitely learned something! Thanks

  • @shepherdej1010
    @shepherdej1010 2 ปีที่แล้ว +1

    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?

  • @vamonosraza4361
    @vamonosraza4361 2 ปีที่แล้ว

    I am So grateful for your videos!

  • @biswarana4491
    @biswarana4491 ปีที่แล้ว +5

    Cat be like : things i need to comply with for some food..

  • @isleschild
    @isleschild 7 หลายเดือนก่อน

    thanks for the work, this was excellent.

  • @eduardoprado8055
    @eduardoprado8055 ปีที่แล้ว

    Awesome explanation!

  • @Anderzon1994
    @Anderzon1994 2 ปีที่แล้ว

    Thanks for sharing your knowledge! I enjoy watching your tutorials!

  • @petarJK
    @petarJK 2 ปีที่แล้ว

    Excellent video! Very well explained. It's one thing to know something, totally different thing to be able to explain it well. Thanks!

  • @Play_Streams
    @Play_Streams 2 ปีที่แล้ว

    Schrodinger's Optional Cat Box. Great tutorial

  • @ashibindal6644
    @ashibindal6644 4 หลายเดือนก่อน

    The map 😲, thanks for the video

  • @azam11250
    @azam11250 9 หลายเดือนก่อน

    great explaination sir. really liked ur videos and learned a lot. Thanks sir

  • @חייםמלוב
    @חייםמלוב 2 ปีที่แล้ว

    Your channel is my go to for any Java related topic. Thank you!
    Could you please consider making some design patterns tutorials? 🙏🏻

  • @pranavmahajan4190
    @pranavmahajan4190 2 ปีที่แล้ว

    You are superb. Do you have any tutorials on using Mockito?

  • @yashaswipandey7923
    @yashaswipandey7923 2 ปีที่แล้ว

    Thanks man, i needed that.

  • @dennisvanmierlo
    @dennisvanmierlo 2 ปีที่แล้ว

    A cat in a box. It’s the perfect combo👌 Thank you for this great tutorial!

  • @personalaccount1515
    @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

  • @yassineabidarIt
    @yassineabidarIt 2 ปีที่แล้ว

    Great content thank you. Just for Optional the right use case was the use in the public method rather than the private method.

    • @CodingWithJohn
      @CodingWithJohn  2 ปีที่แล้ว

      Yep, generally for a private method it's not really a big deal.

  • @TechOnScreen
    @TechOnScreen 2 ปีที่แล้ว +1

    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..

  • @nahid7994
    @nahid7994 ปีที่แล้ว

    The way you explain things, which is really amazing , really short and exact.
    Can you make a video with Java Stream API? Please. Thanks a lot for sharing great way to learn and grasp things.

  • @skeptic3045
    @skeptic3045 2 ปีที่แล้ว

    Suggestion for video: Design patterns

  • @timmelis4872
    @timmelis4872 2 ปีที่แล้ว

    Another very well explained video ...

  • @nishiths9228
    @nishiths9228 2 ปีที่แล้ว +1

    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 .

  • @pliegosevilla
    @pliegosevilla 2 ปีที่แล้ว

    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!!!!

  • @ultimatehuzefa
    @ultimatehuzefa 2 ปีที่แล้ว

    Best Java Tutor!!

  • @muhammedemad1155
    @muhammedemad1155 2 ปีที่แล้ว

    Great tutorial , thank you

  • @whitneybrown1715
    @whitneybrown1715 2 ปีที่แล้ว

    Awesome tutorial!