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
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
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
Жыл бұрын
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
Жыл бұрын
@@oscarjosefsson9300 you can name it anything you want. E is just standard
@oscarjosefsson9300
Жыл бұрын
@@dd0n396 Thanks! 👍
@alexshepel5599
3 жыл бұрын
Your channel is really helpful. Hope you will continue with this. Don't stop, bro!
@paulinewachira5839
4 ай бұрын
I appreciate how you explain the important concepts in a very simple and brief manner. Try block ,catch block and finally.Thank you
@andrevandenheever6740
3 жыл бұрын
Really like your clear short presentations, thank you. Keep up the good work!
@jamesarden7554
3 жыл бұрын
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
Жыл бұрын
honestly i thought bucky from the newboston did a decent job as well. granted i never made it past video 40 lol.
@cuca3243
Жыл бұрын
You are the best teacher! Now I understand why different exceptions are used.
@adityasharma6132
Жыл бұрын
You are really amazing to explain everything. Never stop to make videos!
@huzaifafaisal5019
3 жыл бұрын
bro you are so underrated, you cleared things up so much after my lecture
@miyaspapa5628
Жыл бұрын
Clear and concise as always. Thanks bro. You're at 999k subs as of today! Congrats on (inevitably) hitting 1 mil!!!
@Edna_Konrad
Жыл бұрын
I really like how basic it all looks like, just for people to understand the concept. Thx bro!
@stephenbond9487
2 жыл бұрын
No cap the best straightforward and simple tutorials ever
@gutside8069
10 ай бұрын
Explained so simply. I really appreciate it. Confidence in Ability to Learn Information . . . Restoring(45%) . . . (99%). . .
@kayleighrenner829
3 жыл бұрын
One of my favorite channels for java on KZitem!!
@skl7714
3 жыл бұрын
I really love java ..U made it more fun and interesting..THANKS BRO!
@kristynicole6201
2 жыл бұрын
Amaaazzzing tutorials, so helpful. Don't stop making tutorials please!
@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!
@omersond4891
3 жыл бұрын
very helpful. i never understood these try catch stuff before. finally i understand. thanks ma bro
@chillwavefrequency8108
Жыл бұрын
Great videos bro. Love that you cover so much in one Channel. Keep it up Bro!
@atulgurung6213
2 ай бұрын
Nicely defined about exception bro, i like the way you teach bro...
@mpbabu80
2 жыл бұрын
Excellent teaching
@danishhussain9642
4 ай бұрын
Great teaching, Bro!
@naledimotsoikha6807
Жыл бұрын
I spent 3hours in class trying to understand this and you do it in 7min52s ... wow you saves me.
@ShermukhammadKarimov
3 ай бұрын
thanks for clear explanation
@xxg3fallxx589
Жыл бұрын
very nice explanation
@eyashamdan4371
3 ай бұрын
Best teacher on all of KZitem!!!
@adarshvardan6825
Жыл бұрын
your videos are very helpful
@kameshwaranr3569
4 ай бұрын
God level explanation bro😎
@eyobabebe7536
2 жыл бұрын
Great explanation, i love the way of teaching , keep doing bro
@vklmao8677
3 жыл бұрын
Ahhh, a siting at my desk with a coffee ....watching a cool KZitem video about it......and do not have to go through stacks overflow what else is needed....COOL!!!!😎😎
@user-eo6sv1gs7p
Ай бұрын
Nice Bruhh I love Your Video
@cosecE
2 жыл бұрын
recommended your channel to all my juniors
@RK_Rom30
2 жыл бұрын
brooo you videos is educational at somehow entertaining hahahaa
@infinitepossibilities2614
2 жыл бұрын
2:22 - Surroud any Dangerous code with the try block. Haha that was amazing bro!
@rochellemellomida9972
3 жыл бұрын
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
3 жыл бұрын
Glad you like them! Thanks for watching Rochelle!
@ivanpryhorshnia6854
2 жыл бұрын
That's quite useful, thanks a lot for a video!
@Garrison86
2 жыл бұрын
Thank you Bro code for the amazing tutorials, they are a life saver.
@issker8840
5 ай бұрын
love your vids bro!
@notahmed6682
4 ай бұрын
i really love the way you explained it, thank you..
@anapopova9199
Жыл бұрын
It was interesting and good to know! Thanks 🙂 I will follow you!
@yusufmarzuki3128
Ай бұрын
good one !!
@shockwave2477
3 жыл бұрын
Great playlist
@avoisavo
4 ай бұрын
very usefullll
@AdelitoTeca-mi6xg
4 ай бұрын
very nice, you´re great on it
@fareskamal4145
2 жыл бұрын
thank u i wish every one explains in ur way
@trinithvihanga5084
4 ай бұрын
goood content
@deltashit
2 жыл бұрын
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?
@fakharjafri3505
11 ай бұрын
I watched this video to solve a question on hackerank, which I haven't solved in 6 months. It seems easy now, thanks bro
@danny.3036
3 жыл бұрын
Thanks, Bro! ☕ You're awesome!
@aliaskararzykulov2361
3 жыл бұрын
good job bro
@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...
@chrisstuff8235
Жыл бұрын
Bien expliqué. Merci Monsieur
@speklex779
11 ай бұрын
dope video
@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
3 жыл бұрын
Glad to have you here Kairav!
@kairavpathak2178
3 жыл бұрын
Could you upload some vids in your gaming channel too? Like maybe once a week if you are busy or something.
@kemann3815
2 жыл бұрын
Another great one 👌
@helenaa1304
9 ай бұрын
Thanks Bro, I really needed this for my comp sci class 👍
@fire_krystal
Жыл бұрын
best explanation out there! thanks sm
@Ragehunter
Жыл бұрын
tysm for the examples it was clearly understandable :)
@azerpashahuseynli444
3 жыл бұрын
Thank you Bro, perfect explanation
@adityasharma6132
Жыл бұрын
continue always
@amada.10
3 жыл бұрын
Hahah I literally like this video, everytime you create a catch function, you don't forget to include a silly word🤪😂😂😂
@user-et7bw8hn9m
7 ай бұрын
bro, your my go to when my teacher fails me. Thank you.
@dhmilan6077
Жыл бұрын
Damn!! What a simple and easy way to teach
@airadjurad8934
9 ай бұрын
good explanation :)
@lm_slayer1
Жыл бұрын
I passed my exam because of you KINGGGGGGGG
@FarizDarari
Жыл бұрын
HUGE THANKS!!!
@alnmet
7 күн бұрын
thx. short and easy to understand
@alanwarthon
Жыл бұрын
Perfect!, thanks.
@user-ed7ue4fu6z
Жыл бұрын
Thanks pal, that was quite helpfull
@user-sn1vn2ik2o
Ай бұрын
awesome!
@codesloth940
2 жыл бұрын
Your my hero bro
@michael_scarn_
Жыл бұрын
Bro, hats off, thanks a million
@fitzsimmons7
6 ай бұрын
thank you, this was helpful
@thanhhuyvu4530
2 жыл бұрын
i understood try-catch. Thanks Bro
@salahadinshemsu6186
Жыл бұрын
Bro!! love you
@113_03
Жыл бұрын
Thank you bro u really saved my life
@Stella-ic7nc
4 ай бұрын
thanks for summarizing what my lecturer spent 1,5h talking about !
@lucnahounou
10 ай бұрын
Thanks!😁
@firsttime8064
Ай бұрын
love u man, thx
@romanrubanovich9273
3 жыл бұрын
Thanks, Bro!
@azizt6773
9 ай бұрын
Bro you are Amazing thank you so much
@mohammadreza1414
6 күн бұрын
Appreciate you bro!
@itzyuzuruclips
Жыл бұрын
Pretty cool bro
@dhrubarajroy_0865
3 жыл бұрын
nice
@hemanthneupane8608
3 жыл бұрын
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
3 жыл бұрын
thanks for watching Hemanth!
@user-rq6ty6ee6z
7 ай бұрын
ur the best
@PatrickWayne07
Жыл бұрын
Thanks Bro!
@danielsullivan5287
Жыл бұрын
actually watching this in class to help me on my lab
Пікірлер: 226