Ads by ProfitSence
Close

Java Program to Print a Pattern of Right Triangle Star

Last Updated on Wednesday 5th Oct 2022

Triangle Pattern in Java

Input any positive integer and it will print the pattern.

Example 1 : Right Triangle Java

			
					public class RightTriangleStar {
    public static void main(String[] args) {
        int k = 6;
        StarPattern(k);
    }
    public static void StarPattern(int n) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j <= i; j++) {
                System.out.print("* ");
            }
            System.out.println();
        }
    }
}

			
	
			
					// * 
// * * 
// * * * 
// * * * * 
// * * * * * 
// * * * * * *