For n = 5

* ** *** **** *****

**Program**

public class Pattern { public void print(int n) { for (int i = 1; i <= n; i++) { for (int j = 1; j <= i; j++) { System.out.print("*"); } System.out.println(); } } }

Given n, the pattern contains n lines. And line i contains i asterisks i.e. first line contains one asterisk, second line contains two asterisks and so on. The loop counter i counts the line number which ranges from 1 to n. The inner loop counter counts from 1 to i, since line i has i asterisks.