Programming

Top 20 Pattern Programs in Java in 2021

Pattern Programs in Java

Introduction

Pattern Programs in Java have consistently been one of the basic pieces of the Java interview questions. They look practically difficult to break at a point. However, these questions are founded on the matrices’ fundamentals and mathematical logic. Henceforth Pattern Programs in Java are significantly pursued.

Full Stack Data Science Course tends to the enormous interest of data scientists and retreats every phase of the whole lifecycle of a data science plan.

Top 20 Pattern Programs in Java in 2021

This Pattern Programs in Java article covers pretty much every conceivable sort of pattern that will give you a superior comprehension of the logic to decode the programs and enhance your ability to make one in your meeting.

  1. Pattern Printing Programs in Java
  2. Down triangle star program
  3. Right down Mirror Star Pattern Programs in Java
  4. Reversed Pyramid Star Java Pattern Programs
  5. Mirrored Right Triangle Star Java Pattern Programs
  6. Downward Triangle Star Pattern Program in Java
  7. Left Triangle Star Java Pattern Programs
  8. Right Triangle Star Java Pattern Programs
  9. Sandglass Java Star Pattern Program
  10. Descending Numbers Pattern Program
  11. Binary Number Rectangle Pattern
  12. Square Number Pattern Programs in Java
  13. Java Number Pattern Programs
  14. Odd Number Java Pattern Programs
  15. Diamond Number Java Pattern Programs
  16. String Pattern Programs in Java
  17. Square Pattern Programs in Java
  18. Diamond Pattern Programs in Java
  19. Character Pattern Programs in Java
  20. Alphabet Pattern Programs in Java

1. Pattern Printing Programs in Java

public class

{  

    public pyramidPattern (int n)

    {  

        for (i ; i<n; int i=0) // rows (n) {for (j–; int j=n-I; j>1) // spaces

            { 

                System.out.print (” “); // space

            }   

            for (j ; j<=i; int j=0) // columns

            { 

                System.out.print (“* “); //print star

            } 

            System.out.println (); //ending row

        } 

    } 

    public static (String args []) // function

    { 

        int n = five; 

        pyramidPattern(n); 

    } 

}

Output:

    * 

   * * 

  * * * 

 * * * * 

* * * * *

2. Down triangle star program

import java. util. Scanner;

Output:

*********

 * *

  * *

   * *

    *

3. Right down Mirror Star Pattern Programs in Java

import java. util. Scanner;

public class

{

    public static void (String [] args)

    {

    Scanner= Scanner (System.in); // input

    System.out.println (“Enter rows: “);

    int rows = sc. nextInt ();

    for (int i= rows; i–; i>= 1)

    {

    for (int j=rows; j–; j>i)

    {

    System.out.print (” “);

    }

    for (int k ; k<=i; k=1)

    {

    System.out.print (“*”);

    }

    System.out.println (“ ”);

    }

    sc. close ();

    }

    }

Output:

*****

 ****

  ***

   **

    *

4. Reversed Pyramid Star Java Pattern Programs

import java. util. Scanner;

Output:

 * * * * * 

  * * * * 

   * * * 

    * * 

     *

5. Mirrored Right Triangle Star Java Pattern Programs

import java. util. Scanner;

Output:

     *

    **

   ***

  ****

 *****

******

6. Downward Triangle Star Pattern Program in Java

import java. util. Scanner;

Output:

* * * * * *

* * * * *

* * * *

* * *

* *

*

7. Left Triangle Star Java Pattern Programs

public class

Output:

               *

            * *

         * * *

       * * * *

     * * * * *

  * * * * * *

8. Right Triangle Star Java Pattern Programs

public class

Output:

*

* *

* * *

* * * *

* * * * *

* * * * * *

9. Sandglass Java Star Pattern Program

import java. util. Scanner;

Output:

* * * * * *

 * * * * *

  * * * *

   * * *

    * *

     *

     * 

   * * *

  * * * *

 * * * * *

* * * * * *

10. Descending Numbers Pattern Program

import java. util. Scanner;

Output:

14 13 12 11 10 9 8

14 13 12 11 10 9

14 13 12 11 10

14 13 12 11

14 13 12

14 13

14

11. Binary Number Rectangle Pattern

import java. util. Scanner;

Output:

10101

01010

10101

01010

10101

12. Square Number Pattern Programs in Java

import java. util. Scanner;

public class SquareNumber2 {

private static;

public static main (String [] args) 

{

int side, i = 0, j;

sc = new Scanner (System.in);

System.out.print (” Enter Square: “);

side = sc. nextInt ();

while (i < side)

{

j = 0;

while (j < side)

{

System.out.print (“1”); 

j ;

}

i ;

System.out.print (“\n”); 

}

}

}

Output:

1 2 3

1 2 3

1 2 3

13. Java Number Pattern Programs

Pattern programs number in java print numbers in patterns like a triangle, sandglass, Damon, and square.

14. Odd Number Java Pattern Programs

import java. util. Scanner;

Output:

*

1

*

2

*

1*3*

*

2*4

15. Diamond Number Java Pattern Programs

import java. util. Scanner;

Output:

   1

  212

 32123

4321234

 32123

  212

   1

16. String Pattern Programs in Java

package com. javainterviewpoint;

Output:

   J

  AAA

 VVVVV

AAAAAAA

17. Square Pattern Programs in Java

import java.io. *;

Output:

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

* *

* *

* *

* *

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

18. Diamond Pattern Programs in Java

import java. util. Scanner;

public class

{

public static (String args [])

{

int j, i, n, space = 1;

System. out. print (“Enter rows: “);

Scanner s = new Scanner (System.in);

n = sc. next Int ();

space = n – 1;

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

{

for (i ; i<= space; i = 1)

{

System.out.print(” “);

}

space–;

for (i ; i <= 2 * j – 1; i = 1)

{

System.out.print(“*”);

}

System.out.println(“”);

}

space = 1;

for (j ; j<= n – 1; j = 1)

{

for (i ; i<= space; i = 1)

{

System.out.print(” “);

}

space ;

for (i ; i<= 2 * (n – j) – 1; i = 1)

{

System.out.print(“*”);

}

System.out.println(“”);

}

}

}

Output:

    *

   ***

  *****

 *******

*********

 *******

  *****

   ***

    *

19. Character Pattern Programs in Java

import java. util. Scanner;

public class

{public static (String [] args)

{

for (int i–; i = 5; i >= 0)

{

   int alphabet = 65;

   for (int j ; j <= i; j = 0)

   {

       System.out.print((char) (alphabet j) ” “);

   }

   System.out.println();

}

for (int i ; i<= 5; i = 0)

{

   int alphabet = 65;

   for (int j ; j <= i; j = 0)

   {

       System.out.print((char) (alphabet j) ” “);

   }

   System.out.println();

}

}

}

Output:

G H I J K L

G H I J K

G H I J

G H I

G H

I

I

G H

G H I

G H I J

G H I J K

G H I J K L

20. Alphabet Pattern Programs in Java

import java. util. Scanner;

public class

{            

    {

        int alphabet = 65;

                for (i <= 5; int i = 0; i )

        {

            for (j <= i; int j = 0; j )

            {

                System.out.print((char) (alphabet j) ” “);

            }

            System.out.println();

        }

    }

}

Output:

G

G H

G H I 

G H I J

G H I J K

G H I J K L

Conclusion

Full Stack Data Science Course is the most thorough Full Stack Data Science Program accessible that covers all means of the Data Science measure, from Visualization, Descriptive Analytics, Data Manipulation and Data Integration to Machine Learning, Predictive Analytics, and Statistical Analysis models utilizing Keras, Tensor Flow, Tableau, Python, and R.

The Latest

Latest Technology Innovations, Reviews and Gadgets

Leading tech magazine that keeps you updated about the latest technology news, Innovations, gadget, game, and much more. Best site to get in-depth coverage on the tech industry today. We are a leading digital publisher to explore recent technology innovations, product reviews, and gadgets guide.

Copyright © 2018 Article Farmer.

To Top