I have code which roughly looks like this:
START
Recursive method A
print("Before Loop")
loop:
for(Object o: list)
{
print("Outer loop top")
for(Object ob: list2)
{
print("Inner loop top")
//do stuff with o & ob e.g. recursively call method A under certain conditions
if(someCondition true)
{
print("Entered")
break loop;
}
print("Inner loop bottom")
}
print("Outer loop bottom")
}
print("After Loop")
END
When the program enters the if statement where someCondition is true it prints
Entered
and then it seems to break from both for loops successfully as it next prints
After Loop
AND THEN!! in the console it prints
inner loop bottom
Outer Loop bottom
Outer loop top
inner loop top
etc.
How is this possible. method A is called recursively from more then 1 place, BUT, if the the reason "inner loop bottom" was next printed because the method was recursively starting again it wouldn't print ïnner loop bottom' first! but "Before loop" and then "Outer loop top", then "Inner loop top" and THEN "inner loop bottom" would be printed. According to the print statements its breaking from both loops and then jumping back into the bottom of the inner loop and continues to cycle through the inner loop. What is going on. Please help! Thank you