What are try and catch keywords in java?

try and catch keywords in java-

In try block we define all exception causing code.

In java try and catch forms a unit.

A catch block catches the exception thrown by preceding try block.

Catch block cannot catch an exception thrown by another try block.

If there is no exception causing code in our program or exception is not raised in our code jvm ignores the try catch block.
Syntax :
try
{
}
Catch(Exception e)
{
}


Posted

in

Tags:

Comments

Leave a Reply