When you use a try-catch block, you're essentially telling the compiler that you're
going to take care of displaying the error messages--no built-in
messages will show. Instead, whatever error prompts you include in the
catch statements will show.
When I run your program, I see your error messages, but no built-in
Java error messages; this is how it should be. Really, the errors are
being thrown--but you're catching them, so Java doesn't display the
default message on the console.
15 Million Students Helped!
Sign up to view the full answer