If you can tell us your problem in detail, we can offer some suggestions.
santhosh.R gowda wrote:
It makes no sense to do this
Ya i know that but i'm asking is there any option to skip finally block
No, you can't skip the finally block. But you can throw an exception in the first line of the finally block to prevent the rest from being executed.
You don't want to do that though. So for real, why do you ask? I am sure there is a better answer to solve your REAL problem, rather than to skip the finally block altogether.
There are probably variations on this, like putting a return statement at the top of the finally block. All in all they would be equivalent to deleting the finally block altogether...
how do i not run code that i want to always run?
the obvious answer is that if you don't want it to always run, don't put it in the finally block. Nobody is forcing you to even HAVE a finally block. The question just doesn't make sense. That's why people are asking you what you REALLY want to do.
Ken Blair (in his 3rd post) in this old thread found another way of skipping the finally
Rob Prime wrote:The short answer is: you can't. The only way to skip the finally block is by terminating the JVM on the spot - using System.exit, crashing it (through some buggy native code), terminating it from outside (using task manager / kill) or by crashing the entire operating system itself.
If they switch on the LHC and it produces a black hole that swallows the Earth, and your computer falls into the black hole just at the moment before it's about to go to the finally-block, then it will be prevented from running!