I have shared number pattern programs in java and alphabet pattern programs in java. In this tutorial I will be sharing 19 star pattern programs in java or different star pattern program in java. This blog post is a good way to kick start your coding skills.
I have taken some star pattern programs in java and tried to solve them. Please add more pattern and code in the comment section.
Read Also : Number pattern programs
Alphabet pattern programs
Star Pattern Programs in Java - Pattern 1
*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
Related Articles
import java.util.Scanner;
public class MainClass
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
//Taking rows value from the user
System.out.println("How many rows you want in this pattern?");
int rows = sc.nextInt();
System.out.println("Here is your pattern....!!!");
for (int i=0; i rows;i++ )
{
for (int j=0; ji; j++)
{
System.out.print("*" + " ");
}
System.out.println();
}
//Close the resources
sc.close();
}
}
Star Pattern Programs in Java - Pattern 2
* * * * * * *
* * * * * *
* * * * *
* * * *
* * *
* *
*
import java.util.Scanner;
public class MainClass
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
//Taking rows value from the user
System.out.println("How many rows you want in this pattern?");
int rows = sc.nextInt();
System.out.println("Here is your pattern....!!!");
for (int i= rows-1; i>=0 ; i--)
{
for (int j=0; ji; j++)
{
System.out.print("*" + " ");
}
System.out.println();
}
//Close the resources
sc.close();
}
}
Star Pattern Programs in Java - Pattern 3
import java.util.Scanner;
public class MainClass
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
//Taking rows value from the user
System.out.println("How many rows you want in this pattern?");
int rows = sc.nextInt();
System.out.println("Here is your pattern....!!!");
for (int i= 0; i rows; i++)
{
for (int j=1; jrows-i; j++)
{
System.out.print(" ");
}
for (int k=0;ki;k++)
{
System.out.print("*");
}
System.out.println("");
}
//Close the resources
sc.close();
}
}
Star Pattern Programs in Java - Pattern 4
import java.util.Scanner;
public class MainClass
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
//Taking rows value from the user
System.out.println("How many rows you want in this pattern?");
int rows = sc.nextInt();
System.out.println("Here is your pattern....!!!");
for (int i= rows; i>= 1; i--)
{
for (int j=rows; j>i;j--)
{
System.out.print(" ");
}
for (int k=1;ki;k++)
{
System.out.print("*");
}
System.out.println("");
}
//Close the resources
sc.close();
}
}
Star Pattern Programs in Java - Pattern 5
*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
import java.util.Scanner;
public class MainClass
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
//Taking rows value from the user
System.out.println("How many rows you want in this pattern?");
int rows = sc.nextInt();
System.out.println("Here is your pattern....!!!");
for (int i= 0; i rows-1 ; i++)
{
for (int j=rows-1; j>i; j--)
{
System.out.print(" ");
}
for (int k=0; ki; k++)
{
System.out.print("*" + " ");
}
System.out.println();
}
//Close the resources
sc.close();
}
}
Star Pattern Programs in Java - Pattern 6
* * * * * * *
* * * * * *
* * * * *
* * * *
* * *
* *
*
import java.util.Scanner;
public class MainClass
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
//Taking rows value from the user
System.out.println("How many rows you want in this pattern?");
int rows = sc.nextInt();
System.out.println("Here is your pattern....!!!");
for (int i= 0; i rows-1 ; i++)
{
for (int j=0; ji; j++)
{
System.out.print(" ");
}
for (int k=0; krows-1-i; k++)
{
System.out.print("*" + " ");
}
System.out.println();
}
//Close the resources
sc.close();
}
}
Star Pattern Programs in Java - Pattern 7
* * * * * * *
* * * * * * *
* * * * * * *
* * * * * * *
* * * * * * *
* * * * * * *
* * * * * * *
import java.util.Scanner;
public class MainClass
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
//Taking rows value from the user
System.out.println("How many rows you want in this pattern?");
int rows = sc.nextInt();
System.out.println("Here is your pattern....!!!");
for (int i= 0; i rows-1 ; i++)
{
for (int j=rows-1; j>i; j--)
{
System.out.printf("*"+" ");
}
for (int k=0; ki; k++)
{
System.out.print("*" + " ");
}
System.out.println("");
}
//Close the resources
sc.close();
}
}
Star Pattern Programs in Java - Pattern 8
*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
* * * * * *
* * * * *
* * * *
* * *
* *
*
import java.util.Scanner;
public class MainClass
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
//Taking rows value from the user
System.out.println("How many rows you want in this pattern?");
int rows = sc.nextInt();
System.out.println("Here is your pattern....!!!");
for (int i= 0; i rows-1 ; i++)
{
for (int j=rows-1; j>=i; j--)
{
System.out.print(" ");
}
for (int k=0; ki; k++)
{
System.out.print("*" + " ");
}
System.out.println("");
}
for (int i= 0; i rows-1 ; i++)
{
for (int j=-1; ji; j++)
{
System.out.print(" ");
}
for (int k=0; krows-2-i; k++)
{
System.out.print("*" + " ");
}
System.out.println("");
}
//Close the resources
sc.close();
}
}
Star Pattern Programs in Java - Pattern 9
* * * * * * *
* * * * * *
* * * * *
* * * *
* * *
* *
*
*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
import java.util.Scanner;
public class MainClass
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
//Taking rows value from the user
System.out.println("How many rows you want in this pattern?");
int rows = sc.nextInt();
System.out.println("Here is your pattern....!!!");
for (int i= 0; i rows-1 ; i++)
{
for (int j=0; j i; j++)
{
System.out.print(" ");
}
for (int k=i; krows-1; k++)
{
System.out.print("*" + " ");
}
System.out.println("");
}
for (int i= rows-1; i>= 0; i--)
{
for (int j=0; j i ;j++)
{
System.out.print(" ");
}
for (int k=i; krows-1; k++)
{
System.out.print("*" + " ");
}
System.out.println("");
}
//Close the resources
sc.close();
}
}
Star Pattern Programs in Java - Pattern 10
*******
******
*****
****
***
**
*
*
**
***
****
*****
******
*******
import java.util.Scanner;
public class MainClass
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
//Taking rows value from the user
System.out.println("How many rows you want in this pattern?");
int rows = sc.nextInt();
System.out.println("Here is your pattern....!!!");
for (int i= 0; i rows-1 ; i++)
{
for (int j=0; j i ;j++)
{
System.out.print(" ");
}
for (int k=i; krows-1; k++)
{
System.out.print("*");
}
System.out