Right Triangle Star Pattern in JAVA

Get Prepinsta Prime

Get all 200+ courses offered by Prepinsta

Never Miss an OffCampus Update

Get OffCampus Updates on Social Media from PrepInsta

Follow us on our Media Handles, we post out OffCampus drives on our Instagram, Telegram, Discord, Whatsdapp etc.

Get Hiring Updates
Amazon,Google,Delottie & 30+companies are hiring ! Get hiring Updates right in your inbox from PrepInsta

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others.

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others.

Get PrepInsta Prime Subscription

Get access to all the courses that PrepInsta offers, check the out below -

Companies

TCS, Cognizant, Delloite, Infosys, Wipro, CoCubes, KPMG, Amazone, ZS Associates, Accenture, Congnizant & other 50+ companies

Programming

Data Structures, Top 500 Codes, C, C++, Java Python & other 10+ subjects

Skills

Full Stack Web Development, Data Science, Machine Learning, AWS Cloud, & other 10+ skills and 20+ projects

OffCampus Updates

Never Miss OffCampus Updates

Get OffCampus Update from PrepInsta

Follow us on our Social Media Handles

Right Triangle Star Pattern

Here we want to print the Right Triangle Star Pattern in Java to do so we need two loop i.e. Outer loop and inner loop.

To print all the star in a row we needed First loop that is the outer loop and For Column we needed second loop that is inner loop mean how many stars you want to put in the single line.so for the desired pattern these two loops are required  here we need to now proper working of the loop that we can easily make a  pattern. Star patterns are a series of * or any other character used to create some pattern 

 

Right triangle star pattern in java

Write a Program to print the following pattern.

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

Working

  • Step 1- First you need to initialize two variable for loop.
  • Step 2- The first loop  for the row.
  • Step 3-  The second loop work for the column.
  • Step 4- Now print the *.
  • Step 5- Now out side of loop, put new line.
  • Step 5- Stop.

Program in Java to print Right Triangle Star Pattern

public class Main
{
       public static void main(String[] args) 
       {
             int i,j;
             //this loop work on the row 
             for(i=0;i<5;i++)
             {
                   //this loop work on the column 
                   for(j=1;j<=i;j++)
                   {
                         System.out.print("* ");
                   }
                   System.out.println();
              }
        }
}

Comments