Java exception handling ⚠️

Поделиться
HTML-код
  • Опубликовано: 5 окт 2020
  • Java exception exceptions handling try catch finally
    #Java #exception #exceptions #handling #try #catch #finally
  • НаукаНаука

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

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

    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 2 года назад +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! 👍

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

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

  • @paulinewachira5839
    @paulinewachira5839 5 месяцев назад +1

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

  • @alexshepel5599
    @alexshepel5599 3 года назад +74

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

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

    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.

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

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

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

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

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

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

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

    One of my favorite channels for java on 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

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

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

  • @gutside8069
    @gutside8069 10 месяцев назад +2

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

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

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

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

    Amaaazzzing tutorials, so helpful. Don't stop making tutorials please!

  • @eyashamdan4371
    @eyashamdan4371 3 месяца назад +1

    Best teacher on all of RUclips!!!

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

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

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

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

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

  • @rochellemellomida9972
    @rochellemellomida9972 3 года назад +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  3 года назад +3

      Glad you like them! Thanks for watching Rochelle!

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

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

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

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

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

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

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

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

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

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

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

    love your vids bro!

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

    best explanation out there! thanks sm

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

    Great teaching, Bro!

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

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

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

    your videos are very helpful

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

    thanks for clear explanation

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

    God level explanation bro😎

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

    Great playlist

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

    tysm for the examples it was clearly understandable :)

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

    brooo you videos is educational at somehow entertaining hahahaa

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

    Excellent teaching

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

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

  • @user-eo6sv1gs7p
    @user-eo6sv1gs7p 2 месяца назад

    Nice Bruhh I love Your Video

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

    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  3 года назад

      Glad to have you here Kairav!

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

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

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

    HUGE THANKS!!!

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

    very nice explanation

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

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

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

    thank you, this was helpful

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

    very nice, you´re great on it

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

    recommended your channel to all my juniors

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

    Perfect!, thanks.

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

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

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

  • @user-ed7ue4fu6z
    @user-ed7ue4fu6z Год назад

    Thanks pal, that was quite helpfull

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

    Bien expliqué.
    Merci Monsieur

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

    Thank you Bro, perfect explanation

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

    i understood try-catch. Thanks Bro

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

    Thank you bro u really saved my life

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

    Thanks, Bro! ☕ You're awesome!

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

    Another great one 👌

  • @hemanthneupane8608
    @hemanthneupane8608 3 года назад +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  3 года назад +1

      thanks for watching Hemanth!

  • @deltashit
    @deltashit 2 года назад +5

    Thank you! Now I finally understand the try and catch blocks.
    But why is the finally block even needed? Could you not just write the code inside the finally block after the whole try-catch and it would still be executed just fine?

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

    good one !!

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

    good explanation :)

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

    Bro, hats off, thanks a million

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

    THANKS YOU SAVED MY DAY

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

    thank u i wish every one explains in ur way

  • @alnmet
    @alnmet 20 дней назад

    thx. short and easy to understand

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

    love u man, thx

  • @lucnahounou
    @lucnahounou 10 месяцев назад +1

    Thanks!😁

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

    Bro!! love you

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

    Damn!! What a simple and easy way to teach

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

    good job bro

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

    very usefullll

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

    dope video

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

    Bro you are Amazing thank you so 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

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

    Your my hero 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🤪😂😂😂

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

    Thanks Bro!

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

    Thanks, Bro!

  • @mohammadreza1414
    @mohammadreza1414 18 дней назад

    Appreciate you bro!

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

    ThankYou !!!

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

    thankx bro

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

    BEST CHANEL EVER

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

    Thank you so much sir.

  • @user-sn1vn2ik2o
    @user-sn1vn2ik2o 2 месяца назад

    awesome!

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

    goood content

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

    I passed my exam because of you KINGGGGGGGG

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

    the best thank you

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

    Thanks Bro.

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

    i love you Bro !!

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

    continue always

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

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

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

    Nice, bro!

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

    Thanks!!!

  • @user-et7bw8hn9m
    @user-et7bw8hn9m 8 месяцев назад

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

  • @user-rq6ty6ee6z
    @user-rq6ty6ee6z 7 месяцев назад

    ur the best

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

    Thank you.

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

    thank you bro.

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

    thanks bro

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

    thanks brocode for the toturial

  • @Emir-yo8ek
    @Emir-yo8ek Год назад

    Ty man!

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

    Bro! Great videos.

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

      Thank you for watching Rory!

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

    Pretty cool bro