2017  Kodetalk | Feedback | Privacy Policy | Terms | About
userimage

How to print a start pattern triangle using java code

How to print a start pattern triangle using java code


userimage

Try below code to print a start triangle pattern


package com.patterns;

public class TrianglrOfStars {
	public static void main(String[] args) {
		int i, j, k;
		for (i = 1; i <= 5; i++) {
			for (j = 4; j >= i; j--) {
				System.out.print(" ");
			}
			for (k = 1; k <= (2 * i - 1); k++) {
				System.out.print("*");
			}
			System.out.println("");
		}
	}
}
Answer is