Exception Handling in Java Tutorial

Поделиться
HTML-код
  • Опубликовано: 27 ноя 2024

Комментарии • 287

  • @TheSisovic
    @TheSisovic 2 года назад +526

    Just to say, i'm an IT student and whenever i see something new about Java in my college i go here to yt and look up on your account since i found out that you're much eaiser to understand than my professors, asistants and mentors are. THANK YOU FOR MAKING ME PASS MY EXAMS!!! xD

    • @jbrfr94
      @jbrfr94 2 года назад +12

      Ditto, he explains everything so clearly, it's insane how much more i can understand from here than from any of my classes lol

    • @bubble0
      @bubble0 2 года назад +3

      Same, but for me i think its the excellent live coding that makes it so easy to understand :D

  • @vannimehta2870
    @vannimehta2870 8 месяцев назад +1

    I am a non IT background person and doing a course in IT currently and your videos are super simple to understand. Thank you!

  • @micleh
    @micleh 2 года назад +110

    3:57 - It's exceptional how you tackle the topics of your videos so comprehensively in such a limited timeframe. I wondered why a colleague of mine could not explain to his students the hierarchy of exceptions, while you cover it in the basics of your tutorial here.
    Your videos are so good that I'm constantly thinking of designing a worksheet where one of your videos is the topic and my students have to prepare the topic of the lessons with the help of both - a flipped classroom principle.
    And before I had actually finished your video, I was thinking about whether you would cover the execution of code after an exception is thrown, and voilà, you also covered that at 9:44.
    Please continue making videos about Java related stuff.

    • @Kfimenenpah
      @Kfimenenpah 2 года назад +3

      In my experience people who don't have a complete understanding themselves have problems explaining it it others :D

    • @azuboof
      @azuboof 2 года назад

      @@Kfimenenpah as Einstein said

    • @sauvikgoel591
      @sauvikgoel591 2 месяца назад

      If you happen to create that worksheet, pls do share it with us also!! Please 🙏

  • @jaredcampbell1975
    @jaredcampbell1975 2 года назад +41

    Thank you for imparting your knowledge to all of us on RUclips! I pay attention to the Java lectures at my University, but you have a way of explaining it better than my professors.

  • @laharibasu9731
    @laharibasu9731 Год назад +21

    The best Java instructor out there. Your videos are a binge watch thing. Thanks for making them simple and interesting. ❤️

  • @GratefulCoder
    @GratefulCoder 11 месяцев назад +2

    You are nothing less than blessing to us Java programmers, Thank You John.

  • @jacobr9741
    @jacobr9741 2 года назад +18

    Thanks for helping us all through Dev School John, you're very articulate and entertaining to boot! I'm sure i speak for us all when i say "We appreciate you".

  • @Jesus_Na_Causa
    @Jesus_Na_Causa 2 года назад +1

    40 minutes watching videos about Exceptions, and I only understood it after I saw yours. Thank you very much!

  • @hovonbonioaleqsanyan
    @hovonbonioaleqsanyan 8 месяцев назад

    Best Java teacher I have ever had. John explains almost any topic in a very understandable way. Thank you very much for your work.

  • @rayverN17yo
    @rayverN17yo 2 года назад +4

    Cant believe this dude doesn't have million of subs. Many time I just watch those videos recreationally haha

  • @TheLexanor
    @TheLexanor 2 года назад +2

    I understand you better than my university teachers who explain it in spanish... ¡Keep it going! ¡Greets from Argentina!

  • @christopherboisvert6902
    @christopherboisvert6902 2 года назад +2

    I am student in computer science in my last year and you thought me some stuff I didn't know. Good Stuff!

  • @prashantbunde
    @prashantbunde 2 года назад +1

    Tomorrow is my external exam watched this now. Understood each and every concept will always be thankful to u!

  • @shanisb95
    @shanisb95 2 года назад +2

    How does it become so SIMPLE when it is YOU who explain it 😃 Another great video, thanks !

  • @tylerhewett3547
    @tylerhewett3547 Год назад +1

    Thank you for taking the time to make these videos! Clear and concise as always, I can't be the only one who gets sad when they search a topic they are having issues with and don't see one of your videos addressing the topic/issue.

  • @binary-star1of20
    @binary-star1of20 3 года назад +12

    Thank you John. You always make it easy to understand. You've really helped me, you have no idea.

  • @ovey2214
    @ovey2214 2 года назад +1

    Thank you for giving a real world example of when a "finally" block makes sense to use! Knowing real world examples of why/ when a particular thing would actually be used is a huge step for me in understanding a concept. A lot of times things are explained without showing a real world example of when it's needed and I get hung up on the thought of "why not just do this other much more simple thing that seems to do the exact same thing?"

  • @aquilhall262
    @aquilhall262 10 месяцев назад

    It's great to have someone explain clearly these very important keystone concepts in Java! Thank you!

  • @alexarditti9416
    @alexarditti9416 3 года назад +5

    John I just want to say thank you. Your videos and explanations are so helpful.

  • @christiangiamalis9924
    @christiangiamalis9924 Год назад +1

    Brother you are saving my college career. The videos are so easy to understand and help me a ton. thank you so much

  • @anyname8803
    @anyname8803 Год назад +3

    a little addition : the code inside "Finally" will execute except if there is SYSTEM.EXIT() in the "try catch"

  • @AdrianTregoning
    @AdrianTregoning Год назад

    When I get stuck I usually come to Coding with John, and then 100% of the time I get unstuck. Thank you.

  • @Antal46
    @Antal46 11 месяцев назад

    I have assignment deadline in one day and 10 hours and you just saved me so much time, I think I can finish it If I dont sleep tonight Thanks!

  • @lalitmetkar
    @lalitmetkar 2 года назад

    Hello John,
    Thanks for such wonderful tutorial.
    One thing that you have missed about finally is, finally is not executed if System.exit(0); is called
    Ex.
    package test;
    public class FinallyExample {
    public static void main(String[] args) {

    try {
    System.out.println(3);
    System.exit(0);
    } catch (Exception e) {
    System.out.println(4);
    } finally {
    System.out.println(5);
    }
    }
    }
    and finally, instead of using finally you could use try with resource

  • @zeppelinmexicano
    @zeppelinmexicano 11 месяцев назад +1

    Good advice to use Finally{} to close connections, etc. Then no matter what might explode in the try { } it won't abandon the connections or leave files open.

  • @manarsalem1685
    @manarsalem1685 6 месяцев назад

    2:33 You aren't alone John! It took me my 90+ pages teacher's notes- where this was written over and over- a 2hour lecture and finally your video to understand that LOL

  • @Lexyvil
    @Lexyvil 2 года назад +1

    This was the best video I could find for a refresher on how to handle exceptions. Very well done!

  • @SaviorOfZeDamned
    @SaviorOfZeDamned 2 года назад

    Subscribing because I’m in class for Java now and your videos have literally explained the content 100x better than the block of instruction. Thank you for being so clear!

  • @fatmatakargbo898
    @fatmatakargbo898 Год назад

    Thank you for taking the frustration out of learning Java. Your content is relatable and easy to understand .

  • @robertoenriquechavezrodrig731
    @robertoenriquechavezrodrig731 2 года назад

    Bro, thank you so much! Your videos are amazing, as a java developer myself, I learn so much from your videos! Even with one year of experience already. God bless you bro and regards from Russia!

  • @SAM-ol5ip
    @SAM-ol5ip Год назад

    you have no idea how much I'm grateful to you! thank you so much John

  • @SchnurriTV
    @SchnurriTV 2 года назад

    Ty mate. I was searching for why the finally block even exists for a long time. But now that i know it too runs even after a return is called, it pretty much clear

  • @matiasmoresi5040
    @matiasmoresi5040 2 года назад

    This channel deserves more reach!
    I love your content! Thank you

  • @majestictrain
    @majestictrain Год назад

    Way better explanation than my algorithms and data structures prof gave. Thanks!

  • @MdRahman-jw7vg
    @MdRahman-jw7vg 6 месяцев назад

    The way he describes Java.. I am encouraged to become a developer now😊

  • @gettingup100
    @gettingup100 2 года назад +2

    Hi. John! Enjoying every single one of your videos. I just wish you were around when I was back in college. You would have saved me a ton of time spent reading all kinds of manuals. Keep up the great work!

  • @6821965
    @6821965 2 года назад +2

    Also you can use try with resources block, to close all connections, without needing to use finally block.

  • @prajwalanimations2376
    @prajwalanimations2376 2 года назад

    I was so confused about the finally block but after watching this video it's all clear to me now. Thank you ❣

    • @aaronmesfine2399
      @aaronmesfine2399 Год назад

      Could you pls help me because I've a problem with understanding the finally block?
      Where is the different between the line system.out.println(End here) and the finally block....I mean we would always execute the system.out.println(End here) instruction

    • @prajwalanimations2376
      @prajwalanimations2376 Год назад

      @@aaronmesfine2399 no you got it all wrong, end here is just a output that we wanna show when we run the program it's optional and finally block will run no matter the case

  • @paulus_germanus
    @paulus_germanus 6 месяцев назад

    You're the best thing that happened to Java since James Gosling

  • @InvinciRD
    @InvinciRD Год назад

    I GENUINELY HOPE THAT THIS GUY IS NOT VERY VERY OLD AND WOULD LEAVE TEACHING AS JOHN IS ONE OF ONLY THOSE TEACHERS WHO I LOVE TO LEARRNN FROM.CLEAR AND CONCISE, INTERESTING, BTS TAKEN CARE OF.JUST LIKE A WOW

  • @DogmaticDoggo
    @DogmaticDoggo День назад

    im grateful you have this channel 😭❤️

  • @hameheroj4030
    @hameheroj4030 Год назад +1

    Guys, you can forget all these videos out there and just watch this one. Everything is fine explained here!

  • @Eljamo_0
    @Eljamo_0 Год назад

    Thank you so much for your videos I am studying a java module and I just wish they explained stuff as simply and nicely as you do!

  • @nidahafeez7981
    @nidahafeez7981 Год назад

    Thanks for these explanations, John! You're the best resource for clear, concise yet comprehensive Java tutorials!

  • @ernestoc.d.1868
    @ernestoc.d.1868 2 года назад

    That final part about the finally behaviour was quite interesting.

  • @computer.tutorials
    @computer.tutorials 10 месяцев назад +1

    Legendary explanation! Thank you so much, John😄

  • @gavinbenes9172
    @gavinbenes9172 Год назад

    Thank you for the beginner friendly and accessible language and context breakdown!! ;-; So much much educational content assumes a certain level of knowledge that makes learning really frustrating when struggling with comprehension. Definitely coming back to this channel to help study class concepts!

  • @yassermouhajir8462
    @yassermouhajir8462 3 года назад +4

    Thank you very much for taking the time to explain this subject in such a magnificent
    way.

  • @davidkopec9442
    @davidkopec9442 8 месяцев назад

    You are an awesome teacher and code writer. Thank you.

  • @dejene8625
    @dejene8625 2 года назад

    John, thank you for your simplified explanation.

  • @vivekneupane8807
    @vivekneupane8807 Год назад +1

    Great man, soo simple and so much in so little time. Perfectly synced video!!

  • @skyratclips6279
    @skyratclips6279 2 года назад

    I learned more from this than my Java 1 college class.

  • @raniaoslh6106
    @raniaoslh6106 Год назад

    best channel explaining java concepts ever!!

  • @codingcoder602
    @codingcoder602 2 года назад

    Man I would have had to read a 100 Pages or more to get less than what I got from your 10 Minute Videos. Thank you very Much!!!

  • @daurtk
    @daurtk Год назад

    I so enjoy your videos John. Every time like illumination. So clear, concise but comprehensive. Thanks a bunch!

  • @barrylauth6838
    @barrylauth6838 2 года назад

    Thx a mill John. Despite the value of your java tutorials, they're actually quite entertaining.

  • @iGleeson
    @iGleeson Год назад

    Handle this exception! This was an EXCEPTIONally useful video tutorial!

  • @Stl71
    @Stl71 2 года назад +2

    I would also like to add, that if you want to do something in java with exceptions and you don't know all the exceptions included, a good ide as Eclipse does this for you.

    • @aidancurtis6581
      @aidancurtis6581 2 года назад

      You can also throw a generic Exception that will catch all, it's quite common to see specific exceptions followed by a generic catch all exception block. IMO

  • @vikasgowdaja6881
    @vikasgowdaja6881 2 года назад +1

    Love❤ From India U r Simply Amazing😊 it feels like whatever the Concept be it becomes easy when u explain it

  • @CHIRONJEETB7
    @CHIRONJEETB7 2 года назад +1

    Thank you John for all the videos, exceptional explanations.

  • @Garrison86
    @Garrison86 2 года назад +1

    Amazing! thank you for taking your time in all your videos, it really helps!

  • @xiomaragonzalez6952
    @xiomaragonzalez6952 Год назад

    wow this video blew my mind! very insightful and easy to understand, thank you.

  • @ikramuddinofficial
    @ikramuddinofficial Год назад

    this is first time when i saw your video. I hope now i can learn whole java coding here

  • @skfotografie
    @skfotografie 4 месяца назад

    This video was really helpful to get into the exception topic. Thanks!

  • @Molotom
    @Molotom 2 года назад +1

    Thanks for the video! It's fun to learn about fringe cases like the return statement in finally :)

  • @zeeg1529
    @zeeg1529 8 месяцев назад

    Thanks for the very good explanation, great job! a couple things I would add to the video:
    Autoclosable and try with resources (you did talk about DB connections/Files you wanna close in finally block, would be great to mention Autoclosable there too).
    But I see that you have a separate video on checked vs unchecked, which I was about to suggest putting here as well, perhaps there's another one on try with resources too.
    All in all, thanks again and keep up the good work!

  • @tramvaj12
    @tramvaj12 Год назад

    I like how my man calls method print but what it does actually is returning value :D. You are my man for naming :D

  • @jamilxt
    @jamilxt 3 года назад +1

    Very helpful & crystal clear explanation. Thank you.

  • @AdityaRaj-xo3hn
    @AdityaRaj-xo3hn 3 года назад +9

    Very helpful video!! You explained all things very clearly
    By the way, what is use of 'throws' keyword &
    Does it make a difference when used with unchecked exceptions?

  • @AnthonyVillegas-bc9xd
    @AnthonyVillegas-bc9xd Год назад

    John’s the real MVP!!! 🙌

  • @chilipismysignature5031
    @chilipismysignature5031 2 года назад +2

    My dude, I absolutely love your videos. I'm currently 2 years into my BA in CompSci and whenever I don't fully understand something I watch your videos and It makes it a lot more clearer. I usually watch slowly, coding along with the video and adding notes as I go. The way you explain things is just leveled up way beyond any of the university CompSci teachers I've encountered. Also you seem like a cool dude lol. Was wondering if you were ever planning to add to your Java course? Most of the topics within, I'm pretty comfortable with. Just curious if you were ever thinking of going further ahead into more like intermediate (idk?) level concepts, maybe like DataStructures/Algorithms etc.

  • @secretsorcerer
    @secretsorcerer 2 года назад +1

    Thank you very much Sir
    You're a great teacher
    Thanks for the last example
    Cleared all my doubts

  • @waleedffx
    @waleedffx 2 года назад

    Your video is very informative, thank you for taking the time to help all who need java help

  • @ArielLegoAndMore
    @ArielLegoAndMore Год назад

    better than my java teacher, awsome video!

  • @jeebeefy9878
    @jeebeefy9878 2 года назад

    Very clear explanation. This man is a god!

  • @Coccoutube
    @Coccoutube 2 года назад

    You're a great teacher John; thanks for sharing you're knowledge with us :)

  • @mahbod95
    @mahbod95 8 месяцев назад

    soo clean, clear and concise. Thank you.

  • @manar2404
    @manar2404 2 года назад +1

    you explained it better than two-hour class, can you explain GUI components

  • @pirminscholl5094
    @pirminscholl5094 10 месяцев назад

    i dont sup to many channels. but you deserve it so much.

  • @LBCreateSpace
    @LBCreateSpace 9 месяцев назад

    Excellent video that makes this crystal clear

  • @protector4286
    @protector4286 Год назад

    bro my uni uploads shitty presentations and if youve missed something tough shit. thank god for your channel.

  • @avinashtadi8569
    @avinashtadi8569 Год назад

    Thanks. I appreciate the easy of explaining the concept

  • @benatakaan613
    @benatakaan613 2 года назад

    Man, your content is just amazing! Thank you so much! 🙏

  • @rachealiperu9375
    @rachealiperu9375 2 года назад

    Your videos are really really good and easy to understand, thanks a lot

  • @harshsrivastav2197
    @harshsrivastav2197 Год назад

    You really make me want to learn Java

  • @chisomemmanuel6160
    @chisomemmanuel6160 Год назад

    Best Tutor ever ❤... Much love from here bro... Who else noticed from the video at length 11:02 that the last line of code didn't execute to print out "End here" or is it because of the return keyword?

  • @mahhingaminggate5028
    @mahhingaminggate5028 Год назад

    Bruh you are a life saver .

  • @michael_scarn_
    @michael_scarn_ Год назад

    Thank you John, your channel is soooo coool! Hats off

  • @pejko89
    @pejko89 2 года назад

    Best Java channel

  • @themattster1989
    @themattster1989 2 года назад

    Subbed and liked, this guy is great at explaining, Thanks John.

  • @kerwinso
    @kerwinso 3 года назад +4

    Great vid as always John. Can you please also explain the "throw" and "throws" keywords? I've seen "throws" in a method signature, but wasn't sure exactly what that did.

    • @CodingWithJohn
      @CodingWithJohn  3 года назад +7

      Thanks! Well I don't have a video on "throw" specifically, but you basically just use it when you want to explicitly throw an exception in a certain situation.
      if (someParameter == null) {
      throw new IllegalArgumentException("Hey someParameter can't be null!");
      }
      Then whatever code is calling this code has to handle that exception however they see fit.
      "Throws" is used in the method signature when the method could throw a certain kind of exception, and it's not being caught anywhere within that method. It mostly has to do with "checked" exceptions. There's a good explanation on how it's used in my most recent video here:
      ruclips.net/video/bCPClyGsVhc/видео.html

  • @manavneekhra5276
    @manavneekhra5276 2 года назад

    To the point videos. Keep making good content John.

  • @Tuxon24rus
    @Tuxon24rus 3 года назад +12

    Hello, John!
    First of all thank you for your videos, they help us a lot!
    I was wondering why line 17 at 11:00 wasn't executed. I thought 'return' in try block is related to this block and it should've forced to exit this 'try'. Or 'try' isn't considered as a method (if not, does it also apply for 'try with resources'?), thus 'return' is making to exit the 'main' method?

    • @CodingWithJohn
      @CodingWithJohn  3 года назад +15

      Good question! A return statement will return out of the method completely, not just outside of the try block. So in this case that return exits the main method, ending the program.
      You'll almost never use a return statement in the main method, and just let it complete the main method as usual. This was just to illustrate that the finally block still gets executed, even though it returns out of the method without executing the print at line 17.

    • @Tuxon24rus
      @Tuxon24rus 3 года назад +2

      @@CodingWithJohn Thank you so much!

    • @zepptonian
      @zepptonian 2 года назад +1

      Tuxon24rus, you may be thinking of the *break* statement, which will exit a block.

  • @muhammadzubair957
    @muhammadzubair957 2 года назад

    Thankyou John. Good Explanation, Please Make more videos on Servlet,JSP,Spring,SpringBoot,Hibernete.

  • @esteramathe675
    @esteramathe675 2 года назад

    So helpful every single video!!! Thank you!

  • @pavankumarn2775
    @pavankumarn2775 2 года назад

    hello john, i learnt java by watching your tutorial videos you makes me easy to understand and i'm very thankful to you....
    will u do videos about user-defined exception....thank you

  • @tanmaykolase2098
    @tanmaykolase2098 6 месяцев назад

    You are simply genius!🙌🏻

  • @Nycto97
    @Nycto97 2 года назад

    Thank you for this simple explanation! Helped me a lot :)

  • @Meppoy
    @Meppoy Год назад

    Thanks for the vid! It was illuminating, though kinda hard to follow. The jumps between different versions of the code forced me to stop it and duplicate the lines in order to try them by myself. Can't say if it's a problem, really, but that's my genuine feedback, so take it or leave it). Once again - big thanks for the explanations.

  • @リンゴ酢-b8g
    @リンゴ酢-b8g 2 года назад

    All objects within the Java exception class hierarchy extend from the Throwable superclass. Only instances of Throwable (or an inherited subclass) are indirectly thrown by the Java Virtual Machine (JVM), or can be directly thrown via a throw statement.