Showing posts with label Arithmetic Exception. Show all posts
Showing posts with label Arithmetic Exception. Show all posts

Thursday, 23 January 2014

throw EXCEPTIONS IN JAVA

Java:Using throw


When to use throw in a Java method declaration?

All methods use the throw statement to throw an exception. The throw statement requires a single argument: a Throwable object. Throwable object are instances of any subclass of the Throwable classThe flow of execution stops immediately after the throw statement;any subsequent statements are not executed.

Wednesday, 22 January 2014

NESTED try STATEMENT

NESTED try IN EXCEPTION HANDLING


Java:nested try-catch blocks with simple example

The try block within a try block is known as nested try block.Sometimes a situation may arise where a part of a block may cause one error and the entire block itself may cause another error. In such cases, exception handlers have to be nested, one within another. In java, this can be done using nested try blocks. A try statement can be inside the block of another try. In a nested try block, every time a try block is entered the context of that exception is pushed on the stack.

USING try AND catch

How to use exception handling keywords try and catch in java

THE try BLOCK


A try statement is used to catch exceptions that might be thrown as your program executes. You should use a try statement whenever you use a statement that might throw an exception,That way,your program won’t crash if the exception occurs.The first step in constructing an exception handler is to enclose the code that might throw an exception within a try block.