Click here to Skip to main content
15,889,867 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everybody,
I have one question about the java that can we include the try block in the catch block.

Thanks,
Amol
Posted
Updated 10-Jan-12 2:46am
v2

Yes you can,Please refer this[^]
 
Share this answer
 
Yes, you can have another cascade try/catch blocks. It's often done.

you might want to read more about it: http://docs.oracle.com/javase/tutorial/essential/exceptions/[^]
 
Share this answer
 
Comments
Nagy Vilmos 10-Jan-12 10:07am    
I juts discovered something from your link, the try-with-resource construct.
Hi,

Yes of course you can, keep in mind that you can wrap any piece of code that could throw an exception with a "try...catch" block ... even if that was inside "catch" block.

Catch block could contain a piece of code that throw an exception so you should catch it to prevent a crash :)

here is a thread talking about this :

exception-handling-try-catch-inside-catch[^]

Best Reagards.
EL GAABEB.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900