Print Stars In Java Example
Chapter:
Control Statements
Last Updated:
15-07-2016 10:18:13 UTC
Program:
/* ............... START ............... */
public class JavaPrintStars {
public static void main(String[] args) {
int row, numberOfStars;
for (row = 1; row <= 10; row++) {
for (numberOfStars = 1; numberOfStars <= row; numberOfStars++) {
System.out.print("*");
}
System.out.println();
}
}
}
/* ............... END ............... */
Output
*
**
***
****
*****
******
*******
********
*********
**********
Notes:
-
By Using Java language you can print triangle shape using for loop and also using while loop.
Tags
Print Stars, Java