Left Triangle Custom Pattern #1 in Java

thumbnail

In this tutorial, you will learn to create left trianle custome pattern #1 in Java.

Example 1:

package patternchallenge;
public class PatternChallenge {
    public static void main(String[] args) {
        leftTriangleCustom1 (5);
    } 
    public static void leftTriangleCustom1(int n){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=i;j++){
                if(i%2==1){
                    System.out.print("*");
                } else {
                    System.out.print("#");
                }
            }
            System.out.println("");
        }
    } 
}

The output will be:

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