Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (6.5k points)
If an exception occurs in my program, is there any way that I can skip going to the 'finally' block?

1 Answer

0 votes
by (11.3k points)

If you have a try-catch-finally setup, the finally block will always execute if an exception occurs. If you're looking for a way around this, you can do a System exit in the try block itself if you never want to trigger the finally block. This is the statement you would use in the try block:

System.exit(0);

To know more intricacies regarding Java programming, you can opt for java certification training which would teach you the concepts of exception handling in a much more structured way. 

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...