Can try statements be nested

Try statements may be tested.

Showing Answers 1 - 2 of 2 Answers

Dhananjay Singh

  • Sep 12th, 2005
 

The try statement can never be nested.

  Was this answer useful?  Yes

vtheivamani

  • Jan 11th, 2007
 

ya ....try statement may also nested...see that below example.....otherwise go through the following links

http://www.ccs.neu.edu/course/com3118/EXCEPTION.html

http://www.javacamp.org/javavscsharp/trycatch.html

nested try/finally statement
class Test
{
    public static void main(String[] args) {
        while (true) {
            try {
                try {
                    System.out.println("Before break");
                    break;
                }
                finally {
                    System.out.println("Innermost finally block");
                }
            }
            finally {
                System.out.println("Outermost finally block");
            }
        }
        System.out.println("After break");
    }
}
prints:
   Before break
   Innermost finally block
   Outermost finally block
   After break

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions