Diamond Pattern Numbers Program in Java

Diamond pattern numbers in java. In the java programming language, the diamond number pattern is used. In this Java  program, the number will be printed in a diamond form. For beginners, a diamond pattern   software that prints the number in a diamond shape is available.

Diamond Defintion

A rhombus, or diamond, is a parallelogram with all of its edges of equal length. In addition to the typical qualities of parallelograms, the diagonals of a rhombus bisect the angles and are perpendicular to each other. While rhombus and trapezium are mathematically defined, diamond (or diamond shape) is a colloquial name for rhombus. A rhombus is a quadrilateral with all sides equal in length. It’s also referred to as an equilateral quadrilateral.

For Loop Definition in Java

The “for” loop in Java is an entry-controlled loop that allows a user to iteratively run a block of statement(s) for a defined number of times. The number of iterations is determined by the test condition specified within the “for” loop. The Java “for” loop is one of the simplest Java loops to grasp. A “For” Loop is used to iterate over a specified block of code a predetermined number of times.

public class Main
{
public static void main(String[] args)
{
for (int i = 1; i <= 4; i++)
{
int n = 10;
for (int j = 1; j<= n - i; j++)
{
System.out.print(" ");
}
for (int k = i; k >= 1; k--)
{
System.out.print(k);
}
for (int l = 2; l <= i; l++)
{
System.out.print(l);
}
System.out.println();
}
for (int i = 3; i >= 1; i--)
{
int n = 9;
for (int j = 0; j<= n - i; j++)
{
System.out.print(" ");
}
for (int k = i; k >= 1; k--)
{
System.out.print(k);
}
for (int l = 2; l <= i; l++)
{
System.out.print(l);
}
System.out.println();
}
}
}

Output

1

212

32123

4321234

32123

212

1