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.
If you use the Scanner class, you only need to catch the InputMismatchException and ArithmeticException to pass all the test cases. There is no need for a catch-all Exception.
Using a catch-all Exception clause is generally a bad idea when writing programs.
Java Exception Handling (Try-catch)
You are viewing a single comment's thread. Return to all comments →
If you use the
Scanner
class, you only need to catch theInputMismatchException
andArithmeticException
to pass all the test cases. There is no need for a catch-all Exception.Using a catch-all Exception clause is generally a bad idea when writing programs.