Tuesday 15 March 2011

java - Continue from the next line after getting exception -


I want to continue from the next line, causing error,

  try { Statement} a; Statement b; Statement c; Hold NullPointerException (NPE) {.....}   

Now suppose that my statement throws an exception, so I want to leave it and I want to move forward with B. Do not advise me to hold / put in the block or any other solution at the end. I just want to know that it is possible with Skip and next statement

Yes, it is possible without the end block

  try {statement A; } Hold (NullPointerException NPE) {.....} Try {statement B; } Hold (NullPointerException NPE) {.....} Try {statement C; } NullPointerException (NPE) {.....}   

On the side note, I really do not like it. If you were able to reach the point where you need to control such kind of flow, then you need to take a step back and redo your code design.

No comments:

Post a Comment