Java exception exceptions handling try catch finally #Java #exception #exceptions #handling #try #catch #finally 2022 AutumnExceptionexception in javaexception in java tutorialexception javaexception java tutorialexceptionsexceptions in javaexceptions in java explainedexceptions javajava catch blockjava exceptionjava exception handlingjava exception handling examplejava exception handling programsjava exceptionsjava try blocklearn java exception handling 41 Comments Bro Code 5年 ago 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(); } } } Zaid Al lwansah 4年 ago thanks bro! Mr. Loser 4年 ago Thanks Atul Rao 4年 ago thank u bro Ania Nowak 4年 ago (❁´◡`❁) Anna Nass 4年 ago catch(Exception e)Pokémon exception handling.Gotta catch ‘em all. Wallstreetbets 4年 ago Understand Olha Simionenko 3年 ago I really like how basic it all looks like, just for people to understand the concept. Thx bro! Geoco Jonn Omaña Rigor 3年 ago But how do you make the user to start at the top of the code again without exiting/closing running the program? Ana Popova 3年 ago It was interesting and good to know! Thanks 🙂 I will follow you! Daniel Milewski 3年 ago bro your channel is gold!! comment for stats. Cornelius L 3年 ago 8 minutes… I'm in a hour and a half lesson just on exception handling. And you just explained like 88% of it in 8 minutes. Simonas Sabaliauskas 3年 ago Bro doing God's work Alex Yakoveno 3年 ago Frank 3年 ago Thanks Naledi Motsoikha 3年 ago I spent 3hours in class trying to understand this and you do it in 7min52s … wow you saves me. Wallstreetbets 3年 ago Watch again cool_huip_ 3年 ago DROP a COMMENT down below Furkan Veli Işık 3年 ago I know when no ones got my back bro code is there for me. Can we get a hallulujah for my man over here??? Aditya sharma 3年 ago You are really amazing to explain everything. Never stop to make videos! Aditya sharma 3年 ago You are really amazing to explain everything. Never stop to make videos! Aditya sharma 3年 ago You are really amazing to explain everything. Never stop to make videos! Aditya sharma 3年 ago continue always Aditya sharma 3年 ago You are really amazing to explain everything. Never stop to make videos! Aditya sharma 3年 ago You are really amazing to explain everything. Never stop to make videos! Aditya sharma 3年 ago You are really amazing to explain everything. Never stop to make videos! Aditya sharma 3年 ago You are really amazing to explain everything. Never stop to make videos! Aditya sharma 3年 ago You are really amazing to explain everything. Never stop to make videos! Aditya sharma 3年 ago You are really amazing to explain everything. Never stop to make videos! Aditya sharma 3年 ago You are really amazing to explain everything. Never stop to make videos! Aditya sharma 3年 ago You are really amazing to explain everything. Never stop to make videos! Aditya sharma 3年 ago You are really amazing to explain everything. Never stop to make videos! Aditya sharma 3年 ago You are really amazing to explain everything. Never stop to make videos! Aditya sharma 3年 ago You are really amazing to explain everything. Never stop to make videos! Aditya sharma 3年 ago You are really amazing to explain everything. Never stop to make videos! Aditya sharma 3年 ago You are really amazing to explain everything. Never stop to make videos! Gokul Prasath 3年 ago thnx as alwayas Sairos 3年 ago thankx bro Rasco 3年 ago Hi, I want to ask when I want to use the input outside the try block, but I put it inside the try block. How can I do that? Because the input is not visible outside the try block. Tejas Ghag 3年 ago best Daniel Sullivan 3年 ago actually watching this in class to help me on my lab Write A Commentコメントを投稿するにはログインしてください。
Bro Code 5年 ago 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(); } } }
Olha Simionenko 3年 ago I really like how basic it all looks like, just for people to understand the concept. Thx bro!
Geoco Jonn Omaña Rigor 3年 ago But how do you make the user to start at the top of the code again without exiting/closing running the program?
Cornelius L 3年 ago 8 minutes… I'm in a hour and a half lesson just on exception handling. And you just explained like 88% of it in 8 minutes.
Naledi Motsoikha 3年 ago I spent 3hours in class trying to understand this and you do it in 7min52s … wow you saves me.
Furkan Veli Işık 3年 ago I know when no ones got my back bro code is there for me. Can we get a hallulujah for my man over here???
Rasco 3年 ago Hi, I want to ask when I want to use the input outside the try block, but I put it inside the try block. How can I do that? Because the input is not visible outside the try block.
41 Comments
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();
}
}
}
thanks bro!
Thanks
thank u bro
(❁´◡`❁)
catch(Exception e)
Pokémon exception handling.
Gotta catch ‘em all.
Understand
I really like how basic it all looks like, just for people to understand the concept. Thx bro!
But how do you make the user to start at the top of the code again without exiting/closing running the program?
It was interesting and good to know! Thanks 🙂 I will follow you!
bro your channel is gold!! comment for stats.
8 minutes… I'm in a hour and a half lesson just on exception handling. And you just explained like 88% of it in 8 minutes.
Bro doing God's work
Thanks
I spent 3hours in class trying to understand this and you do it in 7min52s … wow you saves me.
Watch again
DROP a COMMENT down below
I know when no ones got my back bro code is there for me. Can we get a hallulujah for my man over here???
You are really amazing to explain everything. Never stop to make videos!
You are really amazing to explain everything. Never stop to make videos!
You are really amazing to explain everything. Never stop to make videos!
continue always
You are really amazing to explain everything. Never stop to make videos!
You are really amazing to explain everything. Never stop to make videos!
You are really amazing to explain everything. Never stop to make videos!
You are really amazing to explain everything. Never stop to make videos!
You are really amazing to explain everything. Never stop to make videos!
You are really amazing to explain everything. Never stop to make videos!
You are really amazing to explain everything. Never stop to make videos!
You are really amazing to explain everything. Never stop to make videos!
You are really amazing to explain everything. Never stop to make videos!
You are really amazing to explain everything. Never stop to make videos!
You are really amazing to explain everything. Never stop to make videos!
You are really amazing to explain everything. Never stop to make videos!
You are really amazing to explain everything. Never stop to make videos!
thnx as alwayas
thankx bro
Hi, I want to ask when I want to use the input outside the try block, but I put it inside the try block. How can I do that? Because the input is not visible outside the try block.
best
actually watching this in class to help me on my lab