Solid rectangle with numbers pattern 2 in java.

 import java.util.*;

class Pattern {

    public static void main(String[] args) {

        Scanner sc= new Scanner(System.in);

        System.out.println("enter the n and m=");

        int n=sc.nextInt();

        int m=sc.nextInt();

        for(int i=1; i<=n; i++){

            for(int j=1; j<= m; j++){

                System.out.print(i+" ");

            }

            System.out.println();

        }

    }

}


■》Output->

enter the n and m=

5

7

1 1 1 1 1 1 1

2 2 2 2 2 2 2

3 3 3 3 3 3 3

4 4 4 4 4 4 4

5 5 5 5 5 5 5





Comments

Popular posts from this blog

Introduction of java Programming language.

Stack data structure.