Patterns for Interview preparation , using simple trick !

Patterns in java

Program :

Write a program to solve given pattern .


Patterns for Interview preparation , using simple trick !

Solution :

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

Leave a Reply