Program to print given star pattern in Java using simple Trick !

Simple pattern in java
Simple pattern in java

Program :

Write a program to print given pattern !

Star pattern in Java

Solution :

Here Is the Java code to print the given pattern.

public class Pattern {
	public static void main(String[] args) {
		for (int i = 0; i <5; i++) {
			for (int j = 0; j < 5; j++) {
				if(  i+j>=4) //
				{
					System.out.print("*");
				}
				else
				{
					System.out.print(" ");
				}
			}
			System.out.println();
		}
	}
}

Leave a Reply