Pattern Reverse Pyramid Program in Java
public class Pattern34
{
public static void main(String[] args)
{
for (int i = 5; i >= 1; i--)
{
for (int j = 5 - i; j >= 1; j--)
{
System.out.print(" ");
}
for (int j = 1; j <= 2 * i - 1; j++)
{
System.out.print("*");
}
System.out.println();
}
}
}
Output:
********* ******* ***** *** *
public class Pattern35
{
public static void main(String[] args)
{
for (int i = 5; i >= 1; i--)
{
for (int j = 5 - i; j >= 1; j--)
{
System.out.print(" ");
}
for (int j = 1; j <= 2 * i - 1; j++)
{
System.out.print(i);
}
System.out.println();
}
}
}
Output:
555555555 4444444 33333 222 1
public class Pattern36
{
public static void main(String[] args)
{
for (int i = 5; i >= 1; i--)
{
for (int j = 5 - i; j >= 1; j--)
{
System.out.print(" ");
}
for (int j = 1; j <= i; j++)
{
System.out.print(j);
}
for (int j = i - 1; j >= 1; j--)
{
System.out.print(j);
}
System.out.println();
}
}
}
Output:
123454321 1234321 12321 121 1b. tech. bca icse java java tutorials learn java mca programs