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

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

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

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

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

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();
}
}