Placing one
while loop with in the body of another while is called Nested while loop in java programm. Similar to nested loop.
Nesting
while, do-while will work similar to Nested for Loop In Java.
Nested while example CODE class NestedWhileExample OUTPUT 1 5 DESCRIPTION Here outer loop is executed for values going from 1 till less than 3 i.e. 1 and 2. Similarly inner loop is executed from 5 till less than 8 i.e. 5, 6 and 7. So when outer is 1, inner will become 5, 6, and 7 and when outer is 2, then also inner will become 5, 6, and 7. THINGS TO TRY
|