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.
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
*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
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; j<=i; 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; j<=i; j++)
{
System.out.print("*" + " ");
}
System.out.println();
}
//Close the resources
sc.close();
}
}
Star Pattern Programs in Java - Pattern 3
![right triangle mirror star program right triangle mirror star program](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvav4Oaqh5qCWSOJa_2y4PZ481Chj_EGiRk0x1Qr2xXuuEBHEfB745_PWuptpC6wfG_K9YwkRXchyphenhyphenFYAFeeKw6fN5R8T-KELAKu5zntBDrgt86-gRnTezNQOZOrzP4Y4g8mj2Jz_8ft_Jl/s1600/right+triangle+right.png)
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; j<=rows-i; j++)
{
System.out.print(" ");
}
for (int k=0;k<=i;k++)
{
System.out.print("*");
}
System.out.println("");
}
//Close the resources
sc.close();
}
}
Star Pattern Programs in Java - Pattern 4
![right triangle invert star program right triangle invert star program](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmRkW4tAtLEj2DmNitLOgD0YhHueJs8RJTfVf5HavAy1f-Jb87Ud1c4YOxLszAinmFtFQNgCIDR5k4RK5vJA_0zkWkZCi0J7wn_kHQEJCmR7k8Xuz22w7PYuOVOsOReHnj2WsWsmKHjT53/s1600/invert+right+triangle.png)
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;k<=i;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; k<=i; 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; j<=i; j++)
{
System.out.print(" ");
}
for (int k=0; k<=rows-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; k<=i; 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; k<=i; k++)
{
System.out.print("*" + " ");
}
System.out.println("");
}
for (int i= 0; i<= rows-1 ; i++)
{
for (int j=-1; j<=i; j++)
{
System.out.print(" ");
}
for (int k=0; k<=rows-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; k<=rows-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; k<=rows-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; k<=rows-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; k<=rows-1; k++)
{
System.out.print("*");
}
System.out.println("");
}
//Close the resources
sc.close();
}
}
Star Pattern Programs in Java - Pattern 11
* * * * * * *
* * * * * *
* * * * *
* * * *
* * *
* *
*
*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
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=i; j>=0; j--)
{
System.out.print("*"+ " ");
}
System.out.println("");
}
for (int i=0; i<= rows-1; i++)
{
for(int j=i; j >= 0;j--)
{
System.out.print("*"+ " ");
}
System.out.println("");
}
//Close the resources
sc.close();
}
}
Star Pattern Programs in Java - Pattern 12
*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
* * * * * *
* * * * *
* * * *
* * *
* *
*
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("*"+ " ");
}
System.out.println("");
}
for (int i=rows-1; i>=0; i--)
{
for(int j=0; j <= i-1;j++)
{
System.out.print("*"+ " ");
}
System.out.println("");
}
//Close the resources
sc.close();
}
}
Star Pattern Programs in Java - Pattern 13
![left arrow star pattern program left arrow star pattern program](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwgSx1KMMyvnudXkJ3GsU9wQG5U61Y5iDOTywRHMkLC05rqloEryu3qNWosh_vCYsxv-IiUlIvTpjsqktGLDWxBXnoDTdA7Z8olSQjMqlI496D2MVz37qd09EedZp3YdNT1MtIjbA3lSIh/s1600/Arrow+left.png)
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= 1; i<= rows ; i++)
{
for (int j=i; j < rows ;j++) {
System.out.print(" ");
}
for (int k=1; k<=i;k++)
{
System.out.print("*");
}
System.out.println("");
}
for (int i=rows; i>=1; i--)
{
for(int j=i; j<=rows;j++)
{
System.out.print(" ");
}
for(int k=1; k<i ;k++)
{
System.out.print("*");
}
System.out.println("");
}
//Close the resources
sc.close();
}
}
Star Pattern Programs in Java - Pattern 14
*******
*******
*******
*******
*******
*******
*******
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= 1; i<= rows ; i++)
{
for (int j=1; j< i ;j++){
System.out.print(" ");
}
for (int k=1; k<=rows ;k++)
{
System.out.print("*");
}
System.out.println("");
}
//Close the resources
sc.close();
}
}
}
Star Pattern Programs in Java - Pattern 15
*
* *
* *
* *
* *
* *
*******
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=1; i<= rows ; i++)
{
for (int j=1; j<= i ;j++){
if(j==1 || j==i || i==rows) {
System.out.print("*");
}
else {
System.out.print(" ");
}
}
System.out.println("");
}
//Close the resources
sc.close();
}
}
Star Pattern Programs in Java - Pattern 16
*******
* *
* *
* *
* *
* *
*
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=1; i<= rows ; i++)
{
for (int j = rows; j >= i; j--) {
if (j == rows || j == i || i == 1) {
System.out.print("*");
}
else {
System.out.print(" ");
}
}
System.out.println("");
}
//Close the resources
sc.close();
}
}
Star Pattern Programs in Java - Pattern 17
![upper triangle star pattern upper triangle star pattern](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh90nGkS0pnzO-DuUJiwTfPoQXLckdlAwCyspwHb28cVrhC6e0ZfcgdKl7KdthvoXYkLsxucuQx7qB8Fy6EcyzENzPK8OGsgltg7yyHkCpehmI5NDN-r61S_r1mMcCpTMqJobOh_8Nx2C1P/s1600/upper+triangle.png)
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=1; i<= rows ; i++)
{
for (int j = i; j < rows ; j++) {
System.out.print(" ");
}
for (int k = 1; k <= (2*i -1) ;k++) {
if( k==1 || i == rows || k==(2*i-1)) {
System.out.print("*");
}
else {
System.out.print(" ");
}
}
System.out.println("");
}
//Close the resources
sc.close();
}
}
Star Pattern Programs in Java - Pattern 18
![lower triangle star pattern lower triangle star pattern](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWnqb0LsNGO059Bmg-dt5uNL6BvNnE1MMaAHKn2oSXKShLE4I-GBvLUGYTHiGzujxTWIrpHlg_B5Tr0WBQ8dvA77Gpm3rondBxzrCuUWEb9K3uFed97zINKiys2lPWieQ7R99Ya24JCSEK/s1600/lower+triangle.png)
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 = i; j < rows ; j++) {
System.out.print(" ");
}
for (int k = 1; k <= (2*i -1) ;k++) {
if( k==1 || i == rows || k==(2*i-1)) {
System.out.print("*");
}
else {
System.out.print(" ");
}
}
System.out.println("");
}
//Close the resources
sc.close();
}
}
Star Pattern Programs in Java - Pattern 19
*
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
*
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=1; i<= rows ; i++)
{
for (int j = rows; j > i ; j--) {
System.out.print(" ");
}
System.out.print("*");
for (int k = 1; k < 2*(i -1) ;k++) {
System.out.print(" ");
}
if( i==1) {
System.out.println("");
}
else {
System.out.println("*");
}
}
for (int i=rows-1; i>= 1 ; i--)
{
for (int j = rows; j > i ; j--) {
System.out.print(" ");
}
System.out.print("*");
for (int k = 1; k < 2*(i -1) ;k++) {
System.out.print(" ");
}
if( i==1)
System.out.println("");
else
System.out.println("*");
}
//Close the resources
sc.close();
}
}