Home >>Java Programs >Java Program to Print the following Pattern
In this example, we will see a program to print the above-given pattern on the console in Java.
Algorithm:
public class Main
{
public static void main(String[] args) {
for (int i = 1; i <= 10; i++)
{
for (int j = 1; j <= 10; j++)
{
if (i==1 || i==10 || j==1 || j==10 )
System.out.print(" 1");
else
System.out.print(" ");
}
System.out.println();
}
}
}
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1