Mega Code Archive

 
Categories / Java Book / 001 Language Basics
 

0059 Nested for Loops

For example, here is a program that nests for loops: public class Main { public static void main(String args[]) { for (int i = 0; i < 10; i++) { for (int j = i; j < 10; j++) System.out.print("."); System.out.println(); } } } The output produced by this program is shown here: .......... ......... ........ ....... ...... ..... .... ... .. .