nested for loops in java with examples

0

nested loops are a loop inside another loop,

please give me examples of it

 

 

what is the output of the following code:

for (int i = 1; i <= 3; i++) { 
 for (int j = i; j <= 3; j++) { 
 System.out.print(" "+ j); 
 } 
 System.out.println(); 
} 

 

answer:

1 2 3 
 2 3 
 3

 

 

All Contributions

total contributions (0)

New to examplegeek.com?

Join us