Java for loop print shape using nested for loop 1

Question

We would like to output the following shape using nested for loop.


*
**
***/*ww w . j a va  2 s.  co m*/
****
*****
******
*******
********
*********


public class Main {
  public static void main(String[] args) {
    for (int i = 0; i < 10; i++) {
      for (int j = 0; j < i; j++) {
        System.out.print('*');
      }
      System.out.println();
    }
  }
}



PreviousNext

Related