Write a Java program to draw pattern 3

Write a Java program to draw a pattern like mentioned below:

Java Program-  Pattern 3

public class DrawPattern3 {
 
	public static void main(String[] args) {
		int rows = 5;
		int cols = 6;
		for (int row = 1; row <= rows; row++) {
			for (int col = 1; col <= cols; col++) {
				if(col <= cols-row){
					System.out.print(col);
				} else {
					System.out.print("&");
				}
				
			}
			System.out.println();
		}
 
	}
}

Author: Mahesh

Technical Lead with 10 plus years of experience in developing web applications using Java/J2EE and web technologies. Strong in design and integration problem solving skills. Ability to learn, unlearn and relearn with strong written and verbal communications.