Java-Nested For Loop

Nested For Loop

The placing of one loop inside the body of another loop is called nesting.  When you nest two loops, the outer loop takes control of the number of complete repetitions of the inner loop.

Program

1

Program Source

class Javaapp {

    public static void main(String[] args) {
     
        for(int i=0;i<5;i++)
        {
            for(int j=0;j<5;j++)
            {
                System.out.print(" "+j);
            }
            System.out.println();
        }
    }
}

Leave a Comment