Learn EXCEPTION HANDLING in 8 minutes! ⚠️ @BroCodez
Learn EXCEPTION HANDLING in 8 minutes! ⚠️  @BroCodez
Uploaded December 2024 | Updated November 2026, 1 day ago
#java #javatutorial #javacourse

import java.util.InputMismatchException;
import java.util.Scanner;

public class Main {
public static void main(String[] args) {

// Exception = An event that interrupts the normal flow of a program
// (Dividing by zero, file not found, mismatch input type)
// Surround any dangerous code with a try{} block
// try{}, catch{}, finally{}

try (Scanner scanner = new Scanner(System.in)) {
System.out.print("Enter a number: ");
int number = scanner.nextInt();
System.out.println(number);
}
catch (InputMismatchException e) {
System.out.println("That wasn't a number!");
}
catch (ArithmeticException e) {
System.out.println("YOU CAN'T DIVIDE BY ZERO!");
}
catch (Exception e) {
// SAFETY NET
System.out.println("Something went wrong");
}
finally {
System.out.println("This always executes");
}
}
}
Learn EXCEPTION HANDLING in 8 minutes! ⚠️Learn the toString() method in 5 minutes! 🎉Learn C math functions in 5 minutes! 🧮Start using Pandas in 2 minutes! 🐼Code an alarm clock using Python! ⏰Java for loops are easy! 🔂Learn 2D arrays in 8 minutes! ⬜Learn break & continue in 2 minutes! 🛑Learn Java arraylists in 9 minutes! 📃Lets code a mad libs game with C programming! 📖C Programming Full Course for free ⚙️Learn octal in 113₈ seconds #coding #computerscience #programming
Bro Code |

Learn EXCEPTION HANDLING in 8 minutes! ⚠️

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER