Answer to Question #3094 in Java | JSP | JSF for Gina

Question #3094
What do the try and the catch commands in Java do?
1
Expert's answer
2011-06-09T07:48:54-0400
try catch commands makes possible to process exceptions. Syntax:
try
{
//your code that may cause exception
}
catch(Exception e) //here can be another call of exception
{
//code that process exceptions
}
final //you can loose this block. Just do not write it. It is not error
{
//code that will be executed any case
}
See documentation to get to know about list exception classes.
example:
try
{
a=b/c;
}
catch(Exception e)
{
System.out.println("Division by zero occured");
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS