Program to generate pyramid triangle example in java.
/** * Program to generate pyramid triangle example in java. * @author W3schools360 */ public class GeneratePyramidTriangleExample { static void generatePyramidTriangle(int rows){ //Logic to generate pyramid triangle. for(int i=1; i<= rows; i++){ for(int j=0; j < i; j++){ System.out.print("*"); } //New line. System.out.println(""); } } public static void main(String args[]){ //method call generatePyramidTriangle(10); } }
Output:
* ** *** **** ***** ****** ******* ******** ********* **********