Java custom exceptions 🛑

  Рет қаралды 69,935

Bro Code

Bro Code

Күн бұрын

java custom user defined exceptions
#java #exceptions #user

Пікірлер: 109
@BroCodez
@BroCodez 4 жыл бұрын
// ***************************************************** public class AgeException extends Exception{ AgeException(String message){ super(message); } } // ***************************************************** import java.util.Scanner; public class Main { public static void main(String args[]){ Scanner scan = new Scanner(System.in); System.out.print("Enter your age: "); int age = scan.nextInt(); try{ checkAge(age); } catch(Exception e) { System.out.println("A problem occured: "+e); } } static void checkAge(int age)throws AgeException{ if(age
@MrMrdahlberg
@MrMrdahlberg 3 жыл бұрын
You're the best programming teacher on youtube! Has helped me tremendously!
@charliedays
@charliedays 12 күн бұрын
Isn't he really something? The introductions and conclusions really lift my mood. Even representing a dragon to defeat the YT algorithm!🤣Content is worth a million dollars! The only thing that I'm hating right now is the nostalgia the electronic music gives me at the end. My high school would play these same tracks when ending classes.😭
@Moritz_-fs8yp
@Moritz_-fs8yp 2 жыл бұрын
You're a legend! These 10 minutes taught me more than my professor did in 1.5 hours.
@joshvduh
@joshvduh 3 ай бұрын
Bro, I’m in a bootcamp right now and I swear you teach better than any teacher I’ve had. I appreciate you 🙏🏾
@skay3264
@skay3264 Жыл бұрын
Thank you, I love how you show thing without unnecessary clogging. Great video
@Garrison86
@Garrison86 2 жыл бұрын
You rock dude! Thanks for the you are a phenomenal teacher, its all about the analogies.
@kristynicole6201
@kristynicole6201 2 жыл бұрын
omfg no one else has a video on this. THANK YOU!!! This was SO HELPFUL.
@vklmao8677
@vklmao8677 3 жыл бұрын
Udemy: We will take your money and will teach you shit Bro: I Am GoNnA EnD ThIS MaN'S WhOlE CaReeR
@BroCodez
@BroCodez 3 жыл бұрын
lololololol
@geraldgenita6742
@geraldgenita6742 2 жыл бұрын
This is my best of best teachers in my programming studies
@rebeccamonroy444
@rebeccamonroy444 2 жыл бұрын
Thank you, I understood about the custom exception, before this video, I didn't have idea how to create one. I subscribed, I'll keep watching more videos
@thomasavery413
@thomasavery413 2 жыл бұрын
Legend!! thank you so much for the help!
@RoadtoRichandRespected
@RoadtoRichandRespected 9 ай бұрын
public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.println("Enter your height in cm: "); int height = scan.nextInt(); try { checkHeight(height); } catch(HeightException e) { System.out.println("You don't reach the minimum height: " + e); } } static void checkHeight(int height) throws HeightException { if(height < 160 ) { throw new HeightException("You are not tall enough to go on the ride."); } else { System.out.println("You are tall enough to go on the ride."); } } } public class HeightException extends Exception{ HeightException(String message){ super(message); } }
@gilantonyborba8163
@gilantonyborba8163 Жыл бұрын
Thanks for everything!!!! U R AMAZING!
@whatever12341
@whatever12341 3 жыл бұрын
Hey thanks a lot for the video! Quick question, on the catching side of the code, you used the "Exception e". If i put there instead of Exception e, my own exception will this be a problem in case other exceptions occur? Is it advisable to keep both the Exception e and add another catch after that for my own exception?
@programmingsabrina127
@programmingsabrina127 Жыл бұрын
Excellent ! Very helpful ! Thank you very much !
@danielmilewski7659
@danielmilewski7659 Жыл бұрын
thanks to you i finnally understand exceptions! Thank you!
@thaumaston
@thaumaston 4 ай бұрын
Bro, why do all this through an "exception" instead of a simple if / else statement? I am not experienced enough to have an opinion. Just trying to understand. Thank you!
@zero0bb
@zero0bb 2 ай бұрын
custom exceptions can also be used to show stacktrace and method calls, information like this not only improves the debugging of code it also makes it a lot cleaner and readable in comparison to bulky if else statements
@Reymax164
@Reymax164 2 ай бұрын
probably not needed for small programs… but in big projects it'll be better to do that. So knowing it is good.
@mohammedhussein4675
@mohammedhussein4675 25 күн бұрын
Just for clarity especially in big projects If you use if else for every exception you will end up having multiple conditions which will be alot confusing. So, instead we use try catch block so when youor someone read your code it’s alot easier to identify what the code does.
@wolanus
@wolanus 3 жыл бұрын
Thanks Bro. Great job. Keep on doing those vids.
@prajjwaltripathi2911
@prajjwaltripathi2911 Жыл бұрын
amazing explanation]
@nawfalnjm5699
@nawfalnjm5699 3 жыл бұрын
your videos are very helpful
@ivanpalica
@ivanpalica Жыл бұрын
Amazing video, helped me a lot :)
@corneliuslumos668
@corneliuslumos668 2 жыл бұрын
Great video
@monykeo317
@monykeo317 Жыл бұрын
Thank you Bro Code, You're the Bro!❤❤
@wolffz4304
@wolffz4304 2 жыл бұрын
Bro, I know it's been a long time since you uploaded this video, but i have a question about custom exceptions: is there a way to make one of those custom tooltips to surround something with a try and catch block with my custom exception faster? You know, when you type something like a dangerous method and it gives you a "quick fix" by surrounding the method call with a try and catch block by itself, is there a way to make a "custom quick fix" by myself?
@furkanveliisk4113
@furkanveliisk4113 Жыл бұрын
thanks for the vids brah
@idrisgundogdu6528
@idrisgundogdu6528 3 жыл бұрын
very useful thnaks...
@mrhems6715
@mrhems6715 Жыл бұрын
bro deserves a million subs. and more.
@ahmedoussama4503
@ahmedoussama4503 2 жыл бұрын
Thank you for your effort 😊 Would you please make a video about do post request to a URL.
@studynotes2082
@studynotes2082 2 жыл бұрын
very clear~ Thanks Bro.
@seekingseaker
@seekingseaker 2 жыл бұрын
Great video!!!
@qpdbwvwdbqp4730
@qpdbwvwdbqp4730 2 жыл бұрын
Thank you so much Bro!
@angelcastineira2561
@angelcastineira2561 4 жыл бұрын
public class NegativeAgeException extends Exception{ NegativeAgeException(String message){ super(message); } } /////////////////////////////////////////////////////////////////////////////////// static void checkAge(int age)throws NegativeAgeException { if (age
@BroCodez
@BroCodez 4 жыл бұрын
I loled at "You must be born to sign up" xD
@fl4shgaming188
@fl4shgaming188 Жыл бұрын
Best Teacher
@mouadessalihi9417
@mouadessalihi9417 3 жыл бұрын
greaaat work broooo
@davidbarnwelljr103
@davidbarnwelljr103 2 жыл бұрын
THANK YOU!!!!
@pruthvinarayana9568
@pruthvinarayana9568 Жыл бұрын
thanks mate❤‍🔥
@khalilzouhir5862
@khalilzouhir5862 2 жыл бұрын
nta nadi a sat
@sihleeundefined1208
@sihleeundefined1208 3 жыл бұрын
Bro, what if we want to use Exceptions for a String/Strings?
@alexshepel5599
@alexshepel5599 3 жыл бұрын
Nice, bro!
@ahmedhani8670
@ahmedhani8670 Жыл бұрын
I have lab about how to make exception, Thank you Bro code.
@jd_6029
@jd_6029 Жыл бұрын
Damn Bro is Amazing
@smburhan6323
@smburhan6323 Жыл бұрын
Thank you very much
@anonimanonim1223
@anonimanonim1223 2 жыл бұрын
Nice
@nikomamedov3767
@nikomamedov3767 8 ай бұрын
you are great bro you so good for my feature thank you for everythings.
@kemann3815
@kemann3815 2 жыл бұрын
Lovely
@oshadhaedirisinghe1455
@oshadhaedirisinghe1455 4 ай бұрын
Thank you
@RahulBhatia-py1iv
@RahulBhatia-py1iv 5 ай бұрын
You are legend 😂🎉
@obi537
@obi537 6 ай бұрын
nice
@shaiknafeezahmed9139
@shaiknafeezahmed9139 2 жыл бұрын
Thank you Bro.... This code helps me alot Bro From Bro Code Bro... ❤️👍😜
@mumtahenahussain3849
@mumtahenahussain3849 2 жыл бұрын
thank you for saving me
@aruldilip9430
@aruldilip9430 2 жыл бұрын
I can't ask for a best teacher
@user-bu8mg7uq3s
@user-bu8mg7uq3s 2 жыл бұрын
thank you so much
@aces8481
@aces8481 2 жыл бұрын
Thanks bro.
@ibrahimylmaz8378
@ibrahimylmaz8378 2 жыл бұрын
thanks bro
@sergeyb6071
@sergeyb6071 4 жыл бұрын
Great tutorial! I was trying to figure out a condition which verifies if a non-numeric key was entered. I'm kinda puzzled..
@BroCodez
@BroCodez 4 жыл бұрын
sweeet
@manar2404
@manar2404 2 жыл бұрын
thank you
@user-uo8we6nd7e
@user-uo8we6nd7e Ай бұрын
thanks ,broo
@emaanrana25
@emaanrana25 Жыл бұрын
Created something similar but made it a PokedexException that only accepts entries 1 to 1008, anything else would throw the exception.
@dagim6625
@dagim6625 4 ай бұрын
Thanks
@codex4630
@codex4630 3 жыл бұрын
How to handle exceptions in return type method?
@hichemkhelifiahmed145
@hichemkhelifiahmed145 6 ай бұрын
you're the best
@SizarieldoR
@SizarieldoR 2 жыл бұрын
Nice, thanks
@BroCodez
@BroCodez 2 жыл бұрын
I remember you Ivan! Hello!
@SizarieldoR
@SizarieldoR 2 жыл бұрын
@@BroCodez Heya
@user-wr6re2sf7t
@user-wr6re2sf7t Ай бұрын
sir love from bangladesh but i have a question why have you used static block in this code
@alexshepel5599
@alexshepel5599 3 жыл бұрын
nice, bro :^)
@girl6994
@girl6994 4 жыл бұрын
Sir,I am very sorry to disturb you. I wonder why in Java IO stream always use 8kb bytes to input or out put data? Why don’t we use a larger size array? If we use a larger size, don’t we just simply get read and write much faster? So why don’t we use a larger size of array? And in sql, we just need to avoid use too much times of IO, we don’t need to worry about limited 8kb, why???
@BroCodez
@BroCodez 4 жыл бұрын
hmmm let me do some research, that is a difficult question. I will see what I can find
@BroCodez
@BroCodez 4 жыл бұрын
I have not yet found the answer, but I did find some documentation that explains IO stream in depth: docs.oracle.com/javase/tutorial/essential/io/streams.html
@girl6994
@girl6994 4 жыл бұрын
Bro Code Buffered byte steams which is BufferedOutputStream and BufferedInputstream, and both of them use 8kb bytes array as buffer area which is 8192 bit.
@leviplays7466
@leviplays7466 2 ай бұрын
you're the bro
@skillraiderv5289
@skillraiderv5289 3 жыл бұрын
Adoro estos videos aunque no sé inglés xD
@tdkq
@tdkq Жыл бұрын
حتى انا😂
@simonnn4136
@simonnn4136 2 ай бұрын
❤❤
@nardi112
@nardi112 11 ай бұрын
honestly idk what i am typing here ,i am just following your command sir😁...ig i can proceed to the video..yeah
@hahahahaha9101
@hahahahaha9101 6 ай бұрын
how did u extend Exception in ageException but there is no exception class???
@Reymax164
@Reymax164 2 ай бұрын
Java has an Exception class by default, like Math class.
@hugoresende5620
@hugoresende5620 2 жыл бұрын
static void checkXP (int x) throws XPExeption{ switch (x){ case 1: System.out.println("NIVEL 1"); break; case 2: System.out.println("NIVEL 2"); break; case 3: System.out.println("NIVEL 3"); break; default: throw new XPExeption("NOT VALID"); } }
@mryoloTHEgreek
@mryoloTHEgreek Ай бұрын
brooooo
@sirajuddinjohar6238
@sirajuddinjohar6238 2 жыл бұрын
Question Write a program to accept email address from a user and throw user defined exception if it does not contain @ symbol. import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc =new Scanner(System.in); System.out.println("Enter Your Email"); String Email =sc.nextLine(); try{ checkEmail(Email); } catch (Exception e){ System.out.println("A Problem occured"+e); } } static void checkEmail(String Email)throws EmailException{ if (Email = ){ throw new EmailException("plese enter valid email:"); } else{ System.out.println("Your are Sign up "); } } } Sir What should we used in if block for verifying It Contain @symbol or not
@kingkock1
@kingkock1 2 жыл бұрын
vunderbar
@amadujalloh4700
@amadujalloh4700 3 жыл бұрын
😎😎😎😎😎😎😎
@kirsty6108
@kirsty6108 4 жыл бұрын
SORRY I came from your first video I need HELP! I accidentally deleted the left hand side of the program where it says package explorer how do I get it back?!!?
@girl6994
@girl6994 4 жыл бұрын
Kirsty Holmes no way. If you use java file’s class method to delete, it will delete forever, it’s not like windows to put files in your garage bin. But if you really need to recover, I can send you a disc scanner software for you to recover. It can recover in most case, but I won’t promise you it will surely success.
@girl6994
@girl6994 4 жыл бұрын
If you use eclipse.
@angelcastineira2561
@angelcastineira2561 4 жыл бұрын
window - show view - package explorer (if you are using eclipse)
@manuelgonzalezpalafox2627
@manuelgonzalezpalafox2627 Жыл бұрын
Ly bro 6
@erek_alone3952
@erek_alone3952 3 жыл бұрын
i think i should see the video at first then commit
@wallstreetbets7741
@wallstreetbets7741 Жыл бұрын
Need rewatch
@beckhamwilson2112
@beckhamwilson2112 Жыл бұрын
algo
@archaeniac7846
@archaeniac7846 2 жыл бұрын
Comment
@konstandinosdimitriou2301
@konstandinosdimitriou2301 11 ай бұрын
comment
@sportler_5411
@sportler_5411 4 ай бұрын
mlmlm
@zstar8397
@zstar8397 Жыл бұрын
Yo just wanna say that GOD loved the world so much he sent his only begotten son Jesus to die a brutal death for us so that we can have eternal life and we can all accept this amazing gift this by simply believing in him (Jesus) asking for the forgiveness of your sins and forming a relationship with heavenly father. ..>>>>....
@honoredegg
@honoredegg 2 жыл бұрын
78th. Thank you, ma Bro Sensei
@MrLoser-ks2xn
@MrLoser-ks2xn 11 ай бұрын
@user-hf8fv2jm1o
@user-hf8fv2jm1o 9 ай бұрын
Thank you
@MrLoser-ks2xn
@MrLoser-ks2xn Жыл бұрын
Thanks
@EnchikO
@EnchikO 2 жыл бұрын
Thank you
@lamias7712
@lamias7712 2 жыл бұрын
Thanks
Java anonymous objects 🃏
10:38
Bro Code
Рет қаралды 15 М.
Java exception handling ⚠️
7:53
Bro Code
Рет қаралды 97 М.
Super sport🤯
00:15
Lexa_Merin
Рет қаралды 20 МЛН
La final estuvo difícil
00:34
Juan De Dios Pantoja
Рет қаралды 27 МЛН
Java HashMap 🗺️
13:05
Bro Code
Рет қаралды 74 М.
Java threads 🧵
16:01
Bro Code
Рет қаралды 103 М.
Modern Graphical User Interfaces in Python
11:12
NeuralNine
Рет қаралды 1,4 МЛН
15 crazy new JS framework features you don’t know yet
6:11
Fireship
Рет қаралды 400 М.
Java Custom Exceptions Tutorial - It's Way Easier Than You Think
14:29
Coding with John
Рет қаралды 144 М.
Java multithreading 🧶
15:18
Bro Code
Рет қаралды 118 М.
How C++ Works
20:21
The Cherno
Рет қаралды 1 МЛН
Easy Ways to Loop Over Objects in JavaScript
11:21
dcode
Рет қаралды 7 М.
The Exception class in Java
19:16
CodeWithHarry
Рет қаралды 198 М.
#miniphone
0:18
Miniphone
Рет қаралды 11 МЛН
Топ-3 суперкрутых ПК из CompShop
1:00
CompShop Shorts
Рет қаралды 261 М.