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

You are currently viewing Program to print given  star pattern in Java using  simple Trick !

Write a Program to print following pattern !

pattrens with java
pattrens with java

Solution :

Here is the Java code print the above 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("*");
				}
			}
			System.out.println();
		}
	}
}

Leave a Reply