To print pyramid pattern in JAVA, use this code...
public static void main(String[] args) {
for(int k=0;k<5;k++) {
for(int k1=0;k1<5-i;k1++) {
System.out.print(" ");
}
for(int k2=0;k2<=k;k2++) {
System.out.print("* ");
}
System.out.println();
}
}
Output:
*
* *
* * *
* * * *
* * * * *