TOP 10 Java Pattern Programs

TOP 10 Java Pattern Programs
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

TOP 10 Java Pattern Programs

1- Square Pattern Programs in Java

* * * *

* * * *

* * * *

* * * *

package pattern;

import java.util.Scanner;

public class pattern_1

{

public static void main(String arg[])

{

Scanner key = new Scanner(System.in);

System.out.print(“Enter the pattern Numbers=”);

int n = key.nextInt();

for (int i = 1; i <= n; i++)

{

for (int j = 1; j <= n; j++)

{ System.out.print(“*”);

}

System.out.println();

}

}

}

2- Right Triangle Star Pattern Java

*

* *

* * *

* * * *

* * * * *

package pattern;

import java.util.Scanner;

public class pattern_2

{ public static void main(String arg[])

{ Scanner key=new Scanner(System.in);

System.out.print(“Enter the pattern Numbers=”);

int n=key.nextInt();

for(int i=1;i<=n;i++)

{

for(int j=1;j<=i;j++)

{

System.out.print(“*”);

}

System.out.println();

}

}

}

3- Downward Triangle Star Pattern Java

* * * * *

* * * *

* * *

* *

*

package pattern;

import java.util.Scanner;

public class pattern_3

{ public static void main(String arg[])

{ Scanner key=new Scanner(System.in);

System.out.print(“Enter the pattern Numbers=”);

int n=key.nextInt();

for(int i=1;i<=n;i++)

{ for(int j=1;j<=n+1-i;j++)

{ System.out.print(“*”);

} System.out.println();

}

}

}

4- Right Numbers Star Pattern Java

1

1 2

1 2 3

1 2 3 4

1 2 3 4 5

package pattern;

import java.util.Scanner;

public class pattern_4

{ public static void main(String arg[])

{ Scanner key=new Scanner(System.in);

System.out.print(“Enter the Pattern Numbers=”);

int n=key.nextInt(); for(int i=1;i<=n;i++)

{ for(int j=1;j<=i;j++)

{ System.out.print(j);

} System.out.println();

}

}

}

5- Right Pascal’s Triangle Java

*

* *

* * *

* * * *

* * * * *

* * * *

* * *

* *

*

package pattern;

import java.util.Scanner; public class pattern_5

{ public static void main(String arg[])

{ Scanner key=new Scanner(System.in);

System.out.print(“Enter The Pattern Numbers=”);

int n= key.nextInt();

for(int i=0;i<=2*n;i++) {

int Total =i>n ? (2*n)-i:i;

for(int j=0;j<Total;j++)

{ System.out.print(“* “);

} System.out.println();

}

}

}

6- Mirrored Right Triangle Star Program Java

*

* *

* * *

* * * *

* * * * *

package pattern;

import java.util.Scanner;

public class pattern_6

{ public static void main(String arg[])

{ Scanner key = new Scanner(System.in);

System.out.print(“Enter the Pattern Numbers=”);

int n = key.nextInt();

for (int i = 1; i <= n; i++)

{ for (int j = 1; j <= n-i; j++)

{ System.out.print(” “);

} for (int j = 1; j <= i; j++)

{ System.out.print(“*”);

} System.out.println();

}

}

}

7- Right down Mirror Star Pattern Java

* * * * *

* * * *

* * *

* *

*

package pattern;

import java.util.Scanner;

public class pattern_7

{ public static void main(String arg[])

{ Scanner key=new Scanner(System.in);

System.out.print(“Enter the Pattern Numbers=”);

int n =key.nextInt();

for(int i=1;i<=n;i++)

{ for(int j=1;j<=i;j++)

{ System.out.print(” “);

}

for(int j=1;j<=n+1-i;j++)

{ System.out.print(“*”);

} System.out.println();

}

}

}

8- Pyramid Star Pattern Java

*

* * *

* * * * *

* * * * * * *

* * * * * * * * *

package pattern;

import java.util.Scanner; public class pattern_8

{ public static void main(String arg[])

{ Scanner key=new Scanner(System.in);

System.out.print(“Enter the pattern numbers=”);

int n=key.nextInt();

for(int i=1;i<=n;i++)

{ for (int j = 1; j <= (2 * n) – 1; j++)

{ if (j >= n+1-i && j <= n-1+i)

System.out.print(“*”);

else

System.out.print(” “);

} System.out.println();

}

}

}

9- Reversed Pyramid Star Pattern java

* * * * * * * * * *

* * * * * * * * *

* * * * * * * *

* * * * * * *

* * * * * *

* * * * *

* * * *

* * *

* *

*

package pattern; import java.util.Scanner; public class Pattern_9

{ public static void main(String arg[])

{ Scanner key=new Scanner(System.in);

System.out.print(“Enter the pattern numbers=”);

int n=key.nextInt();

for(int i=1;i<=n;i++)

{ for (int j = 1; j <= (2 * n) -i; j++)

{ if (j >=i && j <=(2*n)-i)

System.out.print(“*”);

else

System.out.print(” “);

}

System.out.println();

}

}

}

10- Pyramid Star Pattern Java (Type 2)

*

* *

* * *

* * * *

* * * * *

package pattern;

import java.util.Scanner;

public class Pattern_10

{ public static void main(String arg[])

{ Scanner key=new Scanner(System.in);

System.out.print(“Enter the Pattern Numbers=”);

int n= key.nextInt();

for(int i=1;i<=n;i++)

{ for(int j=1;j<=n-i;j++)

{ System.out.print(” “);

} for(int j=1;j<=i;j++)

{ System.out.print(“* “);

} System.out.println();

}

}

}


New Java Pattern Programs Coming Soon………

TOP 10 Java Pattern Programs

Coming Soon…….

TOP 10 Java Pattern Programs

I am Anmol gupta, i warmly welcome you to APNE KO JANO, and hope you liked this article, My mission is to inspire millions of people, i can show you the right path to go ahead.

Leave a Reply

Your email address will not be published. Required fields are marked *