You are viewing a single comment's thread. Return to all comments →
Here's my code. by using getClass().getName() you handle all exceptions that may occur.
try {
try
{
Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); System.out.println(a/b); sc.close(); } catch (ArithmeticException e) { System.out.println(e); } catch (Exception e) { System.out.println(e.getClass().getName()); }
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 →
Here's my code. by using getClass().getName() you handle all exceptions that may occur.