| Author |
returning to a catch block
|
vuthlarhi donald
Ranch Hand
Joined: Jul 31, 2006
Posts: 76
|
|
how can I return to try statement froma a catch block...catching an Exception and then termionates..
|
 |
chinmay s bedarkar
Greenhorn
Joined: Sep 26, 2005
Posts: 1
|
|
|
if you put a "continue" in your catch block, then it should bring you back to the next iteration of for loop.
|
 |
Joanne Neal
Rancher
Joined: Aug 05, 2005
Posts: 3011
|
|
An ArrayOutOfBoundsException does not indicate an invalid password - it means you are trying to read outside the bounds of your array. As I told you in your previous post, change to and you will no longer get the exception
|
Joanne
|
 |
Joanne Neal
Rancher
Joined: Aug 05, 2005
Posts: 3011
|
|
Actually, thinking about it, an ArrayOutOfBoundsException would indicate an invalid password, because you would have checked the password against all the Person objects in your array and not found a match - it is just not the best way to do it. Of course, if this is the case, there is no need to return to your try statement, because you will have already checked all the possible passwords. The better way to do it is using a boolean flag.
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32675
|
|
Joanne is quite right; you are setting up the "for" loop wrongly, and the format for "for" loops is a standard part of beginners' Java. In my opinion catching an ArrayIndexOutOfBoundsException means minus 1 mark automatically! Welcome to the Ranch, Chinmay S Bedarkar. The "continue" is redundant; the loop will repeat after the catch regardless.
|
 |
Raghavan Muthu
Ranch Hand
Joined: Apr 20, 2006
Posts: 3327
|
|
Originally posted by vuthlarhi donald: how can I return to try statement froma a catch block...
To my knowledge, it is NOT possible at all. As all other ranchers suggested, you can alter your program code so as to resolve the issue!
|
Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
|
 |
 |
|
|
subject: returning to a catch block
|
|
|