Example 3

In a similar fashion, there is one more program, called sorting numbers

Write the code for the following output:

11 2 1 2 31 2 3 4

 The code for the preceding output will be:

    for(int i=1;i<5;i++)      // (outer for loop) it will loop for 4 times         {              for(int j=1;j<=i;j++) //(inner for loop)              {                  System.out.print("j");                  System.out.print("\t");              }              System.out.println(" ");         }

Get Hands-On Automation Testing with Java for Beginners now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.