You are viewing a single comment's thread. Return to all comments →
import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.*; import java.util.InputMismatchException;
public class Solution {
public static void main(String[] args) { Scanner scanner = new Scanner(System.in); try { int number = scanner.nextInt(); int number2 = scanner.nextInt(); System.out.println(number / number2); } catch (ArithmeticException e) { System.out.println("java.lang.ArithmeticException: " + e.getMessage()); } catch (InputMismatchException ex) { System.out.println("java.util.InputMismatchException"); } finally { scanner.close(); } }
}
Seems like cookies are disabled on this browser, please enable them to open this website
Java Exception Handling (Try-catch)
You are viewing a single comment's thread. Return to all comments →
import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.*; import java.util.InputMismatchException;
public class Solution {
}