Section 11.3 Example: Handling ArithmeticExceptions and InputMismatchExceptions
• A try
block (p. 447) encloses code that might throw
an exception and code that should not execute if that exception occurs.
• Exceptions may surface through explicitly mentioned code in a try
block, through calls to other methods or even through deeply nested method calls initiated by code in the try
block.
• A catch
block (p. 448) begins with keyword catch
and an exception parameter followed by a block of code that handles the exception. This code executes when the try
block detects the exception.
• At least one catch
block or a finally
block (p. 448) must immediately follow the try
block.
• A catch
block specifies in parentheses an exception parameter identifying ...
Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.