Java exception handling ⚠️

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

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

  • @BroCodez
    @BroCodez  4 года назад +100

    import java.util.InputMismatchException;
    import java.util.Scanner;
    public class Main {
    public static void main(String[] args) {

    // exception = an event that occurs during the execution of a program that,
    // disrupts the normal flow of instructions

    Scanner scanner = new Scanner(System.in);

    try {

    System.out.println("Enter a whole number to divide: ");
    int x = scanner.nextInt();

    System.out.println("Enter a whole number to divide by: ");
    int y = scanner.nextInt();

    int z = x/y;

    System.out.println("result: " + z);
    }
    catch(ArithmeticException e) {
    System.out.println("You can't divide by zero! IDIOT!");
    }
    catch(InputMismatchException e) {
    System.out.println("PLEASE ENTER A NUMBER OMFG!!!");
    }
    catch(Exception e) {
    System.out.println("Something went wrong");
    }
    finally {
    scanner.close();
    }

    }
    }

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

      Why use int not double? cant 5/2 with int...
      try {
      System.out.println("Enter a whole number to divide: ");
      double x = scanner.nextDouble();
      System.out.println("Enter a whole number to divide by: ");
      double y = scanner.nextDouble();
      double z = x/y;
      System.out.println("result: " + z);
      }

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

      @@haruamia7931 this will not throw an exception. If y=0 then z is infinity. Arithmetic exception is thrown only when dealing with integer division - give it a try!.

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

      Excuse my but what is the "e" after Exception? Is e an object?
      Is there any special reason for calling it e?
      Is there a risk of creating more than one object since e is used for all the catchers?

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

      ​@@oscarjosefsson9300 you can name it anything you want. E is just standard

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

      @@dd0n396 Thanks! 👍

  • @jamesarden7554
    @jamesarden7554 3 года назад +47

    This is by far the best explained java course out there and i have seen loads!!! Concepts i have had trouble with are now no problem thanks to this channel plus i have learned stuff i never even knew java could do

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

      honestly i thought bucky from the newboston did a decent job as well. granted i never made it past video 40 lol.

  • @alexshepel5599
    @alexshepel5599 4 года назад +86

    Your channel is really helpful. Hope you will continue with this. Don't stop, bro!

  • @paulinewachira5839
    @paulinewachira5839 9 месяцев назад +3

    I appreciate how you explain the important concepts in a very simple and brief manner. Try block ,catch block and finally.Thank you

  • @gutside8069
    @gutside8069 Год назад +2

    Explained so simply. I really appreciate it.
    Confidence in Ability to Learn Information . . . Restoring(45%) . . . (99%). . .

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

    Really like your clear short presentations, thank you. Keep up the good work!

  • @cuca3243
    @cuca3243 Год назад +2

    You are the best teacher! Now I understand why different exceptions are used.

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

    One of my favorite channels for java on RUclips!!

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

    great simple explaination

  • @huzaifafaisal5019
    @huzaifafaisal5019 3 года назад +6

    bro you are so underrated, you cleared things up so much after my lecture

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

    I spent 3hours in class trying to understand this and you do it in 7min52s ... wow you saves me.

  • @skl7714
    @skl7714 3 года назад +3

    I really love java ..U made it more fun and interesting..THANKS BRO!

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

    Best teacher on all of RUclips!!!

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

    I really like how basic it all looks like, just for people to understand the concept. Thx bro!

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

    No cap the best straightforward and simple tutorials ever

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

    You are really amazing to explain everything. Never stop to make videos!

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

    very helpful. i never understood these try catch stuff before. finally i understand. thanks ma bro

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

    Clear and concise as always. Thanks bro. You're at 999k subs as of today! Congrats on (inevitably) hitting 1 mil!!!

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

    Ahhh, a siting at my desk with a coffee ....watching a cool RUclips video about it......and do not have to go through stacks overflow what else is needed....COOL!!!!😎😎

  • @Sobu_us
    @Sobu_us Месяц назад

    you are very good at it, just I. 7 min you have explain it clearly more than RUclips who does it in 20 min

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

    2:22 - Surroud any Dangerous code with the try block. Haha that was amazing bro!

  • @rochellemellomida9972
    @rochellemellomida9972 4 года назад +5

    Hello bro, i really love watching your videos, these helped me a lot as a self-learner and beginner in java
    greetings from the Philippines♥♥♥

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

      Glad you like them! Thanks for watching Rochelle!

  • @dianamilenaarchilacordoba4632
    @dianamilenaarchilacordoba4632 3 месяца назад

    great video!!! I'm infinitely grateful for your dedication and big heart to share this knowledge with the world. Thank you soo much

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

    I watched this video to solve a question on hackerank, which I haven't solved in 6 months. It seems easy now, thanks bro

  • @atulgurung6213
    @atulgurung6213 7 месяцев назад

    Nicely defined about exception bro, i like the way you teach bro...

  • @amada.10
    @amada.10 3 года назад +4

    Hahah I literally like this video, everytime you create a catch function, you don't forget to include a silly word🤪😂😂😂

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

    Great videos bro. Love that you cover so much in one Channel. Keep it up Bro!

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

    This just helped me out so much. Thank you fellow bro

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

    Now i know how to handle exception. Thanks bro.

  • @Stella-ic7nc
    @Stella-ic7nc 10 месяцев назад

    thanks for summarizing what my lecturer spent 1,5h talking about !

  • @amadujalloh4700
    @amadujalloh4700 4 года назад

    Geez what is more beautiful than reading Big Java text book and watching the practicals here with my bro?
    Nothing is better in Java than @Bro code...

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

    i really love the way you explained it, thank you..

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

    brooo you videos is educational at somehow entertaining hahahaa

  • @kairavpathak2178
    @kairavpathak2178 4 года назад

    I subbed. Ur videos are so easy to understand. Thank god I found your channel. Otherwise I would be lost in the yt coding world

    • @BroCodez
      @BroCodez  4 года назад

      Glad to have you here Kairav!

    • @kairavpathak2178
      @kairavpathak2178 4 года назад +1

      Could you upload some vids in your gaming channel too? Like maybe once a week if you are busy or something.

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

    I passed my exam because of you KINGGGGGGGG

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

    bro, your my go to when my teacher fails me. Thank you.

  • @cosecE
    @cosecE 3 года назад

    recommended your channel to all my juniors

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

    thank u i wish every one explains in ur way

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

    Appreciate how you explain how to put the exception in blocks, I have been trying to find a decent example of how it works with the code portion. Thank you!

  • @mpbabu80
    @mpbabu80 3 года назад

    Excellent teaching

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

    God level explanation bro😎

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

    Thanks Bro, I really needed this for my comp sci class 👍

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

    best explanation out there! thanks sm

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

    Damn!! What a simple and easy way to teach

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

    thanks for clear explanation

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

    Thank you Bro code for the amazing tutorials, they are a life saver.

  • @eyobabebe7536
    @eyobabebe7536 3 года назад

    Great explanation, i love the way of teaching , keep doing bro

  • @adanskiesabaria
    @adanskiesabaria 7 месяцев назад

    Nice Bruhh I love Your Video

  • @shockwave2477
    @shockwave2477 4 года назад +1

    Great playlist

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

    I subscribed your channel right away I saw this series. I was having trouble learning java and i had not found any good videos on youtube.
    Thank you! Your videos are helping me all way out!

    • @BroCodez
      @BroCodez  4 года назад +1

      thanks for watching Hemanth!

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

    goood content

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

    your videos are very helpful

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

    Bien expliqué.
    Merci Monsieur

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

    DROP a COMMENT down below

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

    dope video

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

    continue always

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

    very usefullll

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

    It was interesting and good to know! Thanks 🙂 I will follow you!

  • @African_Ninja
    @African_Ninja 3 месяца назад

    Last minute studying, thanks bro 😂🔥💔

  • @Aman-xo4yx
    @Aman-xo4yx 9 месяцев назад

    my go to java tutorial channel

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

    good one !!

  • @alnmet
    @alnmet 5 месяцев назад

    thx. short and easy to understand

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

    Great teaching, Bro!

  • @113_03
    @113_03 Год назад

    Thank you bro u really saved my life

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

    tysm for the examples it was clearly understandable :)

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

    BEST CHANEL EVER

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

    actually watching this in class to help me on my lab

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

    That's quite useful, thanks a lot for a video!

  • @AdelitoTeca-mi6xg
    @AdelitoTeca-mi6xg 9 месяцев назад

    very nice, you´re great on it

  • @kemann3815
    @kemann3815 3 года назад

    Another great one 👌

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

    love your vids bro!

  • @thanhhuyvu4530
    @thanhhuyvu4530 3 года назад

    i understood try-catch. Thanks Bro

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

    IDK if anyone cares or not but what I liked the most was the fact that in the thumbnail, Naruhodo is screaming "Exception".

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

      Yes! Somebody understands the reference!

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

    Thanks Bro!

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

    Bro, hats off, thanks a million

  • @azerpashahuseynli444
    @azerpashahuseynli444 3 года назад

    Thank you Bro, perfect explanation

  • @danny.3036
    @danny.3036 3 года назад

    Thanks, Bro! ☕ You're awesome!

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

    THANKS YOU SAVED MY DAY

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

    good explanation :)

  • @aliaskararzykulov2361
    @aliaskararzykulov2361 3 года назад

    good job bro

  • @МаксимЯрема-е8щ
    @МаксимЯрема-е8щ Год назад

    Thanks pal, that was quite helpfull

  • @dhrubarajroy_0865
    @dhrubarajroy_0865 3 года назад

    nice

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

    Bro you are Amazing thank you so much

  • @steatze
    @steatze 3 года назад

    RUclips Algorithm, take this comment and use it to spread this AMAZING channel.

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

    Thanks!😁

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

    thank you, this was helpful

  • @YusufAnsari-z9v
    @YusufAnsari-z9v 7 месяцев назад

    awesome!

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

    Perfect!, thanks.

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

    HUGE THANKS!!!

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

    Your my hero bro

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

    best

  • @GaurabSharma-oo8xu
    @GaurabSharma-oo8xu 8 месяцев назад

    should the error be exactly inside the catch parenthesis? like catch (ArithemeticException) for the arithmetic exception

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

    thanks brocode for the toturial

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

    Bro doing God's work

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

    catch(Exception e)
    Pokémon exception handling.
    Gotta catch ‘em all.

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

    Bro!! love you

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

    thnx as alwayas

  • @RionHoxha-j9q
    @RionHoxha-j9q Год назад

    ur the best

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

    cheers

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

    Pretty cool bro