JAVA - How To Create A Program To Print Pyramid Stars In Java
In This Java Code We Will See How To Make A Program To Print A Pyramid Using For Loop
In Java Programming Language.
Source Code:
package javaapp;
public class Woirk {
public static void main(String[] args){
int v = 20;//the number of spaces
//20 = how much lines
for(int i = 1; i <= 20; i++)
{
//loop to print spaces
for(int j = 1; j < v; j++)
{
System.out.print(" ");
}
v = v-1;
//loop to print stars
for(int t = 1; t < i*2; t++)
{
System.out.print("*");
}
//create a new Line
System.out.println();
}
}
}
//////////OUTPUT:
Bagikan
JAVA - How To Create A Star Pyramid In Java
4/
5
Oleh
insurance