java custom user defined exceptions #java #exceptions #user
Пікірлер: 109
@BroCodez4 жыл бұрын
// ***************************************************** 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
@MrMrdahlberg3 жыл бұрын
You're the best programming teacher on youtube! Has helped me tremendously!
@charliedays12 күн бұрын
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_-fs8yp2 жыл бұрын
You're a legend! These 10 minutes taught me more than my professor did in 1.5 hours.
@joshvduh3 ай бұрын
Bro, I’m in a bootcamp right now and I swear you teach better than any teacher I’ve had. I appreciate you 🙏🏾
@skay3264 Жыл бұрын
Thank you, I love how you show thing without unnecessary clogging. Great video
@Garrison862 жыл бұрын
You rock dude! Thanks for the you are a phenomenal teacher, its all about the analogies.
@kristynicole62012 жыл бұрын
omfg no one else has a video on this. THANK YOU!!! This was SO HELPFUL.
@vklmao86773 жыл бұрын
Udemy: We will take your money and will teach you shit Bro: I Am GoNnA EnD ThIS MaN'S WhOlE CaReeR
@BroCodez3 жыл бұрын
lololololol
@geraldgenita67422 жыл бұрын
This is my best of best teachers in my programming studies
@rebeccamonroy4442 жыл бұрын
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
@thomasavery4132 жыл бұрын
Legend!! thank you so much for the help!
@RoadtoRichandRespected9 ай бұрын
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 Жыл бұрын
Thanks for everything!!!! U R AMAZING!
@whatever123413 жыл бұрын
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 Жыл бұрын
Excellent ! Very helpful ! Thank you very much !
@danielmilewski7659 Жыл бұрын
thanks to you i finnally understand exceptions! Thank you!
@thaumaston4 ай бұрын
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!
@zero0bb2 ай бұрын
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
@Reymax1642 ай бұрын
probably not needed for small programs… but in big projects it'll be better to do that. So knowing it is good.
@mohammedhussein467525 күн бұрын
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.
@wolanus3 жыл бұрын
Thanks Bro. Great job. Keep on doing those vids.
@prajjwaltripathi2911 Жыл бұрын
amazing explanation]
@nawfalnjm56993 жыл бұрын
your videos are very helpful
@ivanpalica Жыл бұрын
Amazing video, helped me a lot :)
@corneliuslumos6682 жыл бұрын
Great video
@monykeo317 Жыл бұрын
Thank you Bro Code, You're the Bro!❤❤
@wolffz43042 жыл бұрын
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 Жыл бұрын
thanks for the vids brah
@idrisgundogdu65283 жыл бұрын
very useful thnaks...
@mrhems6715 Жыл бұрын
bro deserves a million subs. and more.
@ahmedoussama45032 жыл бұрын
Thank you for your effort 😊 Would you please make a video about do post request to a URL.
@studynotes20822 жыл бұрын
very clear~ Thanks Bro.
@seekingseaker2 жыл бұрын
Great video!!!
@qpdbwvwdbqp47302 жыл бұрын
Thank you so much Bro!
@angelcastineira25614 жыл бұрын
public class NegativeAgeException extends Exception{ NegativeAgeException(String message){ super(message); } } /////////////////////////////////////////////////////////////////////////////////// static void checkAge(int age)throws NegativeAgeException { if (age
@BroCodez4 жыл бұрын
I loled at "You must be born to sign up" xD
@fl4shgaming188 Жыл бұрын
Best Teacher
@mouadessalihi94173 жыл бұрын
greaaat work broooo
@davidbarnwelljr1032 жыл бұрын
THANK YOU!!!!
@pruthvinarayana9568 Жыл бұрын
thanks mate❤🔥
@khalilzouhir58622 жыл бұрын
nta nadi a sat
@sihleeundefined12083 жыл бұрын
Bro, what if we want to use Exceptions for a String/Strings?
@alexshepel55993 жыл бұрын
Nice, bro!
@ahmedhani8670 Жыл бұрын
I have lab about how to make exception, Thank you Bro code.
@jd_6029 Жыл бұрын
Damn Bro is Amazing
@smburhan6323 Жыл бұрын
Thank you very much
@anonimanonim12232 жыл бұрын
Nice
@nikomamedov37678 ай бұрын
you are great bro you so good for my feature thank you for everythings.
@kemann38152 жыл бұрын
Lovely
@oshadhaedirisinghe14554 ай бұрын
Thank you
@RahulBhatia-py1iv5 ай бұрын
You are legend 😂🎉
@obi5376 ай бұрын
nice
@shaiknafeezahmed91392 жыл бұрын
Thank you Bro.... This code helps me alot Bro From Bro Code Bro... ❤️👍😜
@mumtahenahussain38492 жыл бұрын
thank you for saving me
@aruldilip94302 жыл бұрын
I can't ask for a best teacher
@user-bu8mg7uq3s2 жыл бұрын
thank you so much
@aces84812 жыл бұрын
Thanks bro.
@ibrahimylmaz83782 жыл бұрын
thanks bro
@sergeyb60714 жыл бұрын
Great tutorial! I was trying to figure out a condition which verifies if a non-numeric key was entered. I'm kinda puzzled..
@BroCodez4 жыл бұрын
sweeet
@manar24042 жыл бұрын
thank you
@user-uo8we6nd7eАй бұрын
thanks ,broo
@emaanrana25 Жыл бұрын
Created something similar but made it a PokedexException that only accepts entries 1 to 1008, anything else would throw the exception.
@dagim66254 ай бұрын
Thanks
@codex46303 жыл бұрын
How to handle exceptions in return type method?
@hichemkhelifiahmed1456 ай бұрын
you're the best
@SizarieldoR2 жыл бұрын
Nice, thanks
@BroCodez2 жыл бұрын
I remember you Ivan! Hello!
@SizarieldoR2 жыл бұрын
@@BroCodez Heya
@user-wr6re2sf7tАй бұрын
sir love from bangladesh but i have a question why have you used static block in this code
@alexshepel55993 жыл бұрын
nice, bro :^)
@girl69944 жыл бұрын
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???
@BroCodez4 жыл бұрын
hmmm let me do some research, that is a difficult question. I will see what I can find
@BroCodez4 жыл бұрын
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
@girl69944 жыл бұрын
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.
@leviplays74662 ай бұрын
you're the bro
@skillraiderv52893 жыл бұрын
Adoro estos videos aunque no sé inglés xD
@tdkq Жыл бұрын
حتى انا😂
@simonnn41362 ай бұрын
❤❤
@nardi11211 ай бұрын
honestly idk what i am typing here ,i am just following your command sir😁...ig i can proceed to the video..yeah
@hahahahaha91016 ай бұрын
how did u extend Exception in ageException but there is no exception class???
@Reymax1642 ай бұрын
Java has an Exception class by default, like Math class.
@hugoresende56202 жыл бұрын
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Ай бұрын
brooooo
@sirajuddinjohar62382 жыл бұрын
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
@kingkock12 жыл бұрын
vunderbar
@amadujalloh47003 жыл бұрын
😎😎😎😎😎😎😎
@kirsty61084 жыл бұрын
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?!!?
@girl69944 жыл бұрын
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.
@girl69944 жыл бұрын
If you use eclipse.
@angelcastineira25614 жыл бұрын
window - show view - package explorer (if you are using eclipse)
@manuelgonzalezpalafox2627 Жыл бұрын
Ly bro 6
@erek_alone39523 жыл бұрын
i think i should see the video at first then commit
@wallstreetbets7741 Жыл бұрын
Need rewatch
@beckhamwilson2112 Жыл бұрын
algo
@archaeniac78462 жыл бұрын
Comment
@konstandinosdimitriou230111 ай бұрын
comment
@sportler_54114 ай бұрын
mlmlm
@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. ..>>>>....