We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I think the most important part is how to retrieve the exception
publicstaticvoidmain(String[]args){Scannerscan=newScanner(System.in);try{inta=scan.nextInt();intb=scan.nextInt();intc=a/b;System.out.println(c);}catch(Exceptione){Strings=e.getClass().getCanonicalName();if(s=="java.lang.ArithmeticException"){s+=": / by zero";}System.out.println(s);}}
Java Exception Handling (Try-catch)
You are viewing a single comment's thread. Return to all comments →
I think the most important part is how to retrieve the exception