Right Triangle Star Pattern in Java

thumbnail

In this tutorial, you will learn to create right triangle start pattern in java.

Example 1:

package patternchallenge;

public class PatternChallenge {
    public static void main(String[] args) {
        rightTriangle1 (5);
    }
 
    public static void rightTriangle1(int n){ 
        for(int i=0; i<n; i++){
            for(int j=n-1; j>i; j--){       
                System.out.print(" "); // print Space
            }      
            for(int j=0; j<=i; j++){
                System.out.print("*"); // print Star
            }       
            System.out.println(); // ending line after each row
        } 
    } 
}

The output will be:

    *
   **
  ***
 ****
*****
Back To Top