while (true) {
try {
//create ImportantObject
LoopToGoTo:
for (int i = 0; i < Limit; i++) {
//method in here throws the exception
//ImportantObject is used in here.
}
} catch(Exception e) {
//report error
continue LoopToGoTo;
}
}
I would like to continue at a loop that is inside the try catch block. Is this possible?
EDIT: Sorry, I was not clear on why I couldn't move the try catch to inside the for loop. (edited snippet) If I put the try-catch inside the for loop, the calls inside won't be able to access the ImportantObject.. This is where I was stuck.
EDIT2: Okay, I resolved my problem, albeit without continue with label! I guess the answer to my question is a simple 'no'. Bad habits might be all over the place, but my assignments due in two hours. what can i say :D
//ImportantClass ImportantObject = null;
while (!ranOnce) {
try {
//create ImportantObject
ranOnce = true;
} catch(Exception e) {
//report error
continue;
}
}
for (int i = 0; i < Limit; i++) {
try {
//method in here throws the exception
//ImportantObject is used in here.
} catch(Exception e) {
//report error
continue;
}
}