Computer Applications
What is nested loop ?
Java Nested for Loops
6 Likes
Answer
A loop may contain another loop in its body. This form of a loop is called nested loop. In a nested loop, the inner loop must terminate before the outer loop.
For example:
for(int i = 0; i < 5; i ++) {
for(int j = 0; j < i; j++) {
System.out.print(j + ' ');
}
System.out.println();
}
Answered By
3 Likes
Related Questions
What is the difference between a while and do-while loop ?
How many times is the loop body executed in a do loop, even if the test-condition is false ?
Write a program in Java to display the following pattern:
1 21 321 4321 54321
Write the program in Java to display the following pattern:
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1