Originally posted by sweety singh:
..
Can somebody please explain me this code....
Please post your code using
Code Tags which always helps the people to get the code in a clean way.
A good indentation helps to understand the flow to a good extent in the beginning stage.
Well. You have two for loops one inside another. The outer for loop is labeled as 'outer'.
The outer for loop contains two segments. The first one is the inner for loop and the second is a println statement which prints "outer".
The inner for loop does have two statements, one prints "Hello" and the next is a "continue" statement. Soon after reaching this continue statement, the runtime environment proceeds its flow of execution to place where it is instructed to do so. Here it is asked to proceed with the 'outer' that's why the second statement of outer for loop does NOT get a chance to get executed at all.
Once both the for loops meets their execution condition being false ("i" and "j" reach 5), the println statement present next to the outer for loop gets executed and prints "Good-Bye".
Please read about 'break' and 'continue' statements
here. You will get to know the tactics.
Does that help?