fork download
  1. import java.io.*;
  2. class pyramid
  3. {
  4. public static void printStars(int n)
  5. {
  6. int i, j;
  7.  
  8.  
  9. for(i=0; i<n; i++)
  10. {
  11. for(j=0; j<=i; j++)
  12. {
  13.  
  14. System.out.print("* ");
  15. }
  16. System.out.println();
  17. }
  18. }
  19.  
  20. public static void main(String args[])
  21. {
  22. int n = 5;
  23. printStars(n);
  24. }
  25. }
Success #stdin #stdout 0.07s 27780KB
stdin
Standard input is empty
stdout
* 
* * 
* * * 
* * * * 
* * * * *