Wed. Feb 28th, 2024

If we specify a loop inside another loop then it is called as nested loop. Any loop can be specified inside any other loop any number of times.

Program:

class NestedForLoop{
   public static void main(string[] args) {
    for(int i=1; i<=5;i++) {
       for(int j=1; j<=5;j++) {
         System.out.println("*");
       }
       System.out.println();
      }
    }
 }

Program

lass NestedWhileLoop{
   public static void main(string[] args) {
     int i=1;
     System.out.println("Tables");
      while(i<=10) {
       int j=1;
       while(j<=10) {
         System.out.println(i+"*"+j+"="+(i*j));
          j++;
       }
        i++;
       System.out.println();
      }
    }
 }

By Rajashekar

I’m (Rajashekar) a core Android developer with complimenting skills as a web developer from India. I cherish taking up complex problems and turning them into beautiful interfaces. My love for decrypting the logic and structure of coding keeps me pushing towards writing elegant and proficient code, whether it is Android, PHP, Flutter or any other platforms. You would find me involved in cuisines, reading, travelling during my leisure hours.

Leave a Reply

Your email address will not be published. Required fields are marked *