Java custom exceptions 🛑

preview_player
Показать описание
java custom user defined exceptions

#java #exceptions #user
Рекомендации по теме
Комментарии
Автор

//
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<18) {
throw new AgeException("\n"+"You must be 18+ to sign up");
}
else {
System.out.println("You are now signed up!");
}
}
}

BroCodez
Автор

You're the best programming teacher on youtube! Has helped me tremendously!

MrMrdahlberg
Автор

You're a legend! These 10 minutes taught me more than my professor did in 1.5 hours.

Moritz_-fsyp
Автор

Bro, I’m in a bootcamp right now and I swear you teach better than any teacher I’ve had. I appreciate you 🙏🏾

joshvduh
Автор

Thank you, I love how you show thing without unnecessary clogging. Great video

skay
Автор

You rock dude! Thanks for the you are a phenomenal teacher, its all about the analogies.

Garrison
Автор

omfg no one else has a video on this. THANK YOU!!! This was SO HELPFUL.

kristynicole
Автор

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

rebeccamonroy
Автор

This is my best of best teachers in my programming studies

geraldgenita
Автор

Legend!!
thank you so much for the help!

thomasavery
Автор

Excellent ! Very helpful ! Thank you very much !

programmingsabrina
Автор

Thanks for everything!!!! U R AMAZING!

gilantonyborba
Автор

thanks to you i finnally understand exceptions! Thank you!

danielmilewski
Автор

Thanks Bro. Great job. Keep on doing those vids.

wolanus
Автор

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?

whatever
Автор

Udemy: We will take your money and will teach you shit
Bro: I Am GoNnA EnD ThIS MaN'S WhOlE CaReeR

vklmao
Автор

Thank you Bro Code, You're the Bro!❤❤

monykeo
Автор

bro deserves a million subs. and more.

mrhems
Автор

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?

wolffz
Автор

Thank you for your effort 😊
Would you please make a video about do post request to a URL.

ahmedoussama