this is the problem what i am facing in a large code thats why i elaborate this problem in a small example what i want to do is
value = "abc"; this line(in the try block) may throws or mayn't throws exception(suppose) what i need is when this throws the exception it goes back in the try block and execute this line value = "abc"; again until it throws exception if not throws exception it return the value please guide me as i tried allot but in vain , Regards
The 'flag' variable is not needed here. As soon as you set it to false the next line returns from the method so the false value will never be checked. Rob's code did exactly what you wanted. If you only wanted to exit the loop and not return from the method, you could replace the return with a break.
You could do it using a flag, but you then wouldn't need the return statement.