Right-Angled Triangle Star Pattern in Java

In this tutorial, we will learn how to print a right-angled triangle star pattern in Java. This is one of the simplest and most common pattern programs, often asked in interviews and coding exercises for beginners.

🔺 What is a Right-Angled Triangle Pattern?

It's a triangle with stars aligned to the left, and the number of stars increases with each row.

Example for n = 5:

*
**
***
****
*****

✅ Java Program


public class RightAngledTriangle {
    public static void main(String[] args) {
        int n = 5;

        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= i; j++) {
                System.out.print("*");
            }
            System.out.println();
        }
    }
}

🧠 Interview Tip

Make sure you understand nested loops clearly. Outer loop controls rows, and inner loop controls columns (stars). Try replacing the star with numbers or characters for practice!

🎯 Output

*
**
***
****
*****

📌 Conclusion

This program demonstrates the use of nested loops to generate star patterns. It's a great starting point to practice pattern-based logic in Java. Once you're confident, try other variations like inverted triangles or pyramids!