- 40 Pattern Programs in Java – Number, Star, Alphabet Patterns
- Pattern Programs In Java
- Pattern 1:
- Pattern 2:
- Pattern 3:
- Pattern 4:
- Pattern 5:
- Pattern 6:
- Pattern 7:
- Pattern 8:
- Pattern 9:
- Pattern 10:
- Pattern 11:
- Pattern 12:
- Pattern 13:
- Pattern 14:
- Pattern 15:
- Pattern 16:
- Pattern 17:
- Pattern 18:
- Pattern 19:
- Pattern 20:
- Pattern 21:
- Pattern 22:
- Pattern 23:
- Pattern 24:
- Pattern 25:
- Pattern 26:
- Pattern 27:
- Pattern 28:
- Pattern 29:
- Pattern 30:
- Pattern 31:
- Pattern 32:
- Pattern 33:
- Pattern 34:
- Pattern 35:
- Pattern 36:
- Pattern 37:
- Pattern 38:
- Pattern 39:
- Pattern 40:
- Leave a Reply Cancel reply
- Top 25 Pattern Programs in Java For Printing Patterns
- How to Print Pattern in Java?
- Pattern Programs in Java
- Star Patterns in Java
40 Pattern Programs in Java – Number, Star, Alphabet Patterns
In this article, we will learn to print the different Pattern Programs in Java, it is the most famous interview question as it tests our logical skills and understanding of flow control.
Let’s look into the below possible Pattern Programs in Java which includes Number patterns, Star patterns, and Alphabet patterns.
Pattern Programs In Java
Pattern 1:
package com.javainterviewpoint; public class Pattern1 < public static void main(String[] args) < int rows = 5; System.out.println("## Printing the pattern ##"); for (int i = 1; i System.out.println(); > > >
## Printing the pattern ## 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5
Pattern 2:
package com.javainterviewpoint; public class Pattern2 < public static void main(String[] args) < int alphabet = 65; int rows = 5; System.out.println("## Printing the pattern ##"); for (int i = 1; i System.out.println(); > > >
## Printing the pattern ## A A B A B C A B C D A B C D E
Pattern 3:
package com.javainterviewpoint; public class Pattern3 < public static void main(String[] args) < int rows = 5; System.out.println("## Printing the pattern ##"); for (int i = 1; i System.out.println(); > > >
Pattern 4:
package com.javainterviewpoint; public class Pattern4 < public static void main(String[] args) < int rows = 5; System.out.println("## Printing the pattern ##"); for (int i = 1; i System.out.println(); > > >
## Printing the pattern ## 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5
Pattern 5:
package com.javainterviewpoint; public class Pattern5 < public static void main(String[] args) < int alphabet = 65; int rows = 5; System.out.println("## Printing the pattern ##"); for (int i = 1; i System.out.println(); > > >
## Printing the pattern ## A B B C C C D D D D E E E E E
Pattern 6:
package com.javainterviewpoint; public class Pattern6 < public static void main(String[] args) < int rows = 5; System.out.println("## Printing the pattern ##"); for (int i = 1; i i; j--) < System.out.print(" "); >for (int k = 1; k System.out.println(); > > >
Pattern 7:
package com.javainterviewpoint; public class Pattern7 < public static void main(String[] args) < int rows = 5; System.out.println("## Printing the pattern ##"); for (int i = 1; i i; j--) < System.out.print(" "); >for (int k = 1; k System.out.println(); > > >
## Printing the pattern ## 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5
Pattern 8:
package com.javainterviewpoint; public class Pattern8 < public static void main(String[] args) < int rows = 5; System.out.println("## Printing the pattern ##"); for (int i = rows; i >= 1; i--) < for (int j = 1; j < i; j++) < System.out.print(" "); >for (int k = i; k System.out.println(); > > >
## Printing the pattern ## 5 4 5 3 4 5 2 3 4 5 1 2 3 4 5
Pattern 9:
package com.javainterviewpoint; public class Pattern9 < public static void main(String[] args) < int alphabet = 65; int rows = 5; System.out.println("## Printing the pattern ##"); for (int i = 1; i = i; j--) < System.out.print(" "); >for (int k = 1; k System.out.println(); > > >
## Printing the pattern ## A A B A B C A B C D A B C D E
Pattern 10:
package com.javainterviewpoint; public class Pattern10 < public static void main(String[] args) < int alphabet = 65; int rows = 5; System.out.println("## Printing the pattern ##"); for (int i = rows; i >= 1; i--) < for (int j = 1; j for (int k = i; k System.out.println(); > > >
## Printing the pattern ## E D E C D E B C D E A B C D E
Pattern 11:
package com.javainterviewpoint; public class Pattern11 < public static void main(String[] args) < int rows = 5; System.out.println("## Printing the pattern ##"); for (int i = 1; i i; j--) < System.out.print(" "); >for (int k = 1; k System.out.println(); > > >
Pattern 12:
package com.javainterviewpoint; public class Pattern12 < public static void main(String[] args) < int rows = 5; System.out.println("## Printing the pattern ##"); for (int i = 1; i i; j--) < System.out.print(" "); >for (int k = 1; k System.out.println(); > > >
## Printing the pattern ## 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5
Pattern 13:
package com.javainterviewpoint; public class Pattern13 < public static void main(String[] args) < int alphabet = 65; int rows = 5; System.out.println("## Printing the pattern ##"); for (int i = 1; i i; j--) < System.out.print(" "); >for (int k = 1; k System.out.println(); > > >
## Printing the pattern ## A B B C C C D D D D E E E E E
Pattern 14:
package com.javainterviewpoint; public class Pattern14 < public static void main(String[] args) < int rows = 5; System.out.println("## Printing the pattern ##"); for (int i = rows; i >= 1; i--) < for (int j = 1; j System.out.println(); > > >
## Printing the pattern ## 1 2 3 4 5 1 2 3 4 1 2 3 1 2 1
Pattern 15:
package com.javainterviewpoint; public class Pattern15 < public static void main(String[] args) < int rows = 5; System.out.println("## Printing the pattern ##"); for (int i = 1; i = i; j--) < System.out.print(j + " "); >System.out.println(); > > >
## Printing the pattern ## 5 4 3 2 1 5 4 3 2 5 4 3 5 4 5
Pattern 16:
package com.javainterviewpoint; public class Pattern16 < public static void main(String[] args) < int rows = 5; System.out.println("## Printing the pattern ##"); for (int i = rows; i >= 1; i--) < for (int j = rows; j >= i; j--) < System.out.print(j + " "); >System.out.println(); > > >
## Printing the pattern ## 5 5 4 5 4 3 5 4 3 2 5 4 3 2 1
Pattern 17:
package com.javainterviewpoint; public class Pattern17 < public static void main(String[] args) < int rows = 5; int temp = 1; System.out.println("## Printing the pattern ##"); for (int i = 1; i System.out.println(); > > >
## Printing the pattern ## 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Pattern 18:
package com.javainterviewpoint; public class Pattern18 < public static void main(String[] args) < int alphabet = 65; int rows = 5; System.out.println("## Printing the pattern ##"); for (int i = rows; i >= 1; i--) < for (int j = 1; j System.out.println(); > > >
## Printing the pattern ## A B C D E A B C D A B C A B A
Pattern 19:
package com.javainterviewpoint; public class Pattern19 < public static void main(String[] args) < int alphabet = 65; int rows = 5; System.out.println("## Printing the pattern ##"); for (int i = 1; i = i; j--) < System.out.print((char) (alphabet + j - 1) + " "); >System.out.println(); > > >
## Printing the pattern ## E D C B A E D C B E D C E D E
Pattern 20:
package com.javainterviewpoint; public class Pattern20 < public static void main(String[] args) < int alphabet = 65; int rows = 5; System.out.println("## Printing the pattern ##"); for (int i = rows; i >= 1; i--) < for (int j = rows; j >= i; j--) < System.out.print((char) (alphabet + j - 1) + " "); >System.out.println(); > > >
## Printing the pattern ## E E D E D C E D C B E D C B A
Pattern 21:
package com.javainterviewpoint; public class Pattern21 < public static void main(String[] args) < int alphabet = 65; int rows = 5; System.out.println("## Printing the pattern ##"); for (int i = 1; i System.out.println(); > > >
## Printing the pattern ## A B C D E F G H I J K L M N O
Pattern 22:
package com.javainterviewpoint; public class Pattern22 < public static void main(String[] args) < int rows = 5; System.out.println("## Printing the pattern ##"); for (int i = 1; i i; j--) < System.out.print(" "); >int temp = 1; for (int k = 1; k System.out.println(); > > >
## Printing the pattern ## 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1
Pattern 23:
package com.javainterviewpoint; public class Pattern23 < public static void main(String[] args) < int alphabet = 65; int rows = 5; System.out.println("## Printing the pattern ##"); for (int i = 1; i i; j--) < System.out.print(" "); >int temp = 1; for (int k = 1; k System.out.println(); > > >
## Printing the pattern ## A A A A B A A C C A A D F D A
Pattern 24:
package com.javainterviewpoint; public class Pattern24 < public static void main(String[] args) < int rows = 5; System.out.println("## Printing the pattern ##"); for (int i = 1; i System.out.println(); > for (int i = rows; i >= 1; i--) < for (int j = 1; j < i; j++) < System.out.print(j + " "); >System.out.println(); > > >
## Printing the pattern ## 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 1 2 3 4 1 2 3 1 2 1
Pattern 25:
package com.javainterviewpoint; public class Pattern25 < public static void main(String[] args) < int alphabet = 65; int rows = 5; System.out.println("## Printing the pattern ##"); for (int i = 1; i System.out.println(); > for (int i = rows; i >= 1; i--) < for (int j = 1; j System.out.println(); > > >
## Printing the pattern ## A A B A B C A B C D A B C D E A B C D A B C A B A
Pattern 26:
package com.javainterviewpoint; public class Pattern26 < public static void main(String[] args) < int rows = 5; System.out.println("## Printing the pattern ##"); for (int i = 1; i System.out.println(); > for (int i = 1; i = i; j--) < System.out.print("* "); >System.out.println(); > > >
Pattern 27:
package com.javainterviewpoint; public class Pattern27 < public static void main(String[] args) < int rows = 5; System.out.println("## Printing the pattern ##"); for (int i = 1; i i; j--) < System.out.print(" "); >for (int k = 1; k System.out.println(); > for (int i = 1; i for (int k = rows - 1; k >= i; k--) < System.out.print("* "); >System.out.println(); > > >
Pattern 28:
package com.javainterviewpoint; public class Pattern28 < public static void main(String[] args) < int rows = 5; System.out.println("## Printing the pattern ##"); for (int i = rows; i >= 1; i--) < for (int j = 1; j System.out.println(); > for (int i = 2; i <= rows; i++) < for (int j = 1; j System.out.println(); > > >
## Printing the pattern ## 1 2 3 4 5 1 2 3 4 1 2 3 1 2 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5
Pattern 29:
package com.javainterviewpoint; public class Pattern29 < public static void main(String[] args) < int rows = 5; System.out.println("## Printing the pattern ##"); for (int i = rows; i >= 1; i--) < for (int j = i; j >= 1; j--) < System.out.print(j + " "); >System.out.println(); > for (int i = 2; i = 1; j--) < System.out.print(j + " "); >System.out.println(); > > >
## Printing the pattern ## 5 4 3 2 1 4 3 2 1 3 2 1 2 1 1 2 1 3 2 1 4 3 2 1 5 4 3 2 1
Pattern 30:
package com.javainterviewpoint; public class Pattern30 < public static void main(String[] args) < int alphabet = 65; int rows = 5; System.out.println("## Printing the pattern ##"); for (int i = rows; i >= 1; i--) < for (int j = 1; j System.out.println(); > for (int i = 2; i <= rows; i++) < for (int j = 1; j System.out.println(); > > >
## Printing the pattern ## A B C D E A B C D A B C A B A A B A B C A B C D A B C D E
Pattern 31:
package com.javainterviewpoint; public class Pattern31 < public static void main(String[] args) < int alphabet = 65; int rows = 5; System.out.println("## Printing the pattern ##"); for (int i = rows; i >= 1; i--) < for (int j = i; j >= 1; j--) < System.out.print((char) (alphabet + j - 1) + " "); >System.out.println(); > for (int i = 2; i = 1; j--) < System.out.print((char) (alphabet + j - 1) + " "); >System.out.println(); > > >
## Printing the pattern ## E D C B A D C B A C B A B A A B A C B A D C B A E D C B A
Pattern 32:
package com.javainterviewpoint; public class Pattern32 < public static void main(String[] args) < int rows = 5; System.out.println("## Printing the pattern ##"); for (int i = rows; i >= 1; i--) < for (int j = i; j >= 1; j--) < System.out.print("* "); >System.out.println(); > for (int i = 2; i = 1; j--) < System.out.print("* "); >System.out.println(); > > >
Pattern 33:
package com.javainterviewpoint; public class Pattern33 < public static void main(String[] args) < int rows = 5; System.out.println("## Printing the pattern ##"); for (int i = 1; i i; j--) < System.out.print(" "); >for (int k = 1; k for (int l = i - 1; l >= 1; l--) < System.out.print(l + " "); >System.out.println(); > > >
## Printing the pattern ## 1 1 2 1 1 2 3 2 1 1 2 3 4 3 2 1 1 2 3 4 5 4 3 2 1
Pattern 34:
package com.javainterviewpoint; public class Pattern34 < public static void main(String[] args) < int alphabet = 65; int rows = 5; System.out.println("## Printing the pattern ##"); for (int i = 1; i i; j--) < System.out.print(" "); >for (int k = 1; k for (int l = i - 1; l >= 1; l--) < System.out.print((char) (alphabet + l - 1) + " "); >System.out.println(); > > >
## Printing the pattern ## A A B A A B C B A A B C D C B A A B C D E D C B A
Pattern 35:
package com.javainterviewpoint; public class Pattern35 < public static void main(String[] args) < int rows = 5; System.out.println("## Printing the pattern ##"); for (int i = 1; i System.out.print(i + " "); for (int k = i; k < rows; k++) < System.out.print("0 "); >System.out.println(); > > >
## Printing the pattern ## 1 0 0 0 0 0 2 0 0 0 0 0 3 0 0 0 0 0 4 0 0 0 0 0 5
Pattern 36:
package com.javainterviewpoint; public class Pattern36 < public static void main(String[] args) < int rows = 5; System.out.println("## Printing the pattern ##"); for (int i = 1; i i; j--) < System.out.print(1 + " "); >for (int k = 1; k System.out.println(); > > >
## Printing the pattern ## 1 1 1 1 1 1 1 1 2 2 1 1 3 3 3 1 4 4 4 4 5 5 5 5 5
Pattern 37:
package com.javainterviewpoint; public class Pattern37 < public static void main(String[] args) < int alphabet = 65; int rows = 5; System.out.println("## Printing the pattern ##"); for (int i = 1; i i; j--) < System.out.print((char) (alphabet) + " "); >for (int k = 1; k System.out.println(); > > >
## Printing the pattern ## A A A A A A A A B B A A C C C A D D D D E E E E E
Pattern 38:
package com.javainterviewpoint; public class Pattern38 < public static void main(String[] args) < int rows = 5; System.out.println("## Printing the pattern ##"); for (int i = 1; i i; j--) < System.out.print(" "); >for (int k = 1; k System.out.println(); > for (int i = 1; i for (int k = 1; k System.out.println(); > > >
## Printing the pattern ## 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 1 2 3 4 1 2 3 1 2 1
Pattern 39:
package com.javainterviewpoint; public class Pattern39 < public static void main(String[] args) < int alphabet = 65; int rows = 5; System.out.println("## Printing the pattern ##"); for (int i = 1; i = i; j--) < System.out.print(" "); >for (int k = 1; k System.out.println(); > for (int i = 1; i for (int k = 1; k System.out.println(); > > >
## Printing the pattern ## A A B A B C A B C D A B C D E A B C D A B C A B A
Pattern 40:
package com.javainterviewpoint; public class Pattern40 < public static void main(String[] args) < int rows = 5; System.out.println("## Printing the pattern ##"); for (int i = 1; i i; j--) < System.out.print(" "); >for (int k = 1; k System.out.println(); > for (int i = rows - 1; i >= 1; i--) < for (int j = rows - 1; j >= i; j--) < System.out.print(" "); >for (int k = 1; k System.out.println(); > > >
Do let me know the patterns that need to be added in the comments. Happy Learning !! 🙂
Leave a Reply Cancel reply
This site uses Akismet to reduce spam. Learn how your comment data is processed.
Top 25 Pattern Programs in Java For Printing Patterns
Java is the most popular programming language recognized for its simplicity and versatility. Wide range of applications can also be developed using it, including web, mobile, and desktop applications. In addition, Java offers powerful tools for developers to create complex programs easily and efficiently. One of the most promising features of Java is its ability to create pattern programs that can print numbers in a specific format. Pattern programs are an excellent way to learn Java programming, especially for beginners, since it helps in understanding the syntax and logic of Java programming.
Java Pattern Programs have always been one of the critical parts of the Java Interview questions. They look almost impossible to crack at a point, but these questions are practically based on mathematical logic and matrices’ fundamentals. Hence Java Pattern Programs are greatly sought-after.
This Java Pattern Programs article covers almost every possible type of pattern programs that will give you a better understanding of the logic to decode the pattern and become capable of building one in your interview.
How to Print Pattern in Java?
Printing patterns in Java is a common task in programming, especially in the early stages of learning. Patterns are printed by arranging symbols or numbers in a specific way to form a design or shape. These patterns are often used in problem-solving and can be useful in developing algorithmic thinking skills. This article will discuss how to print patterns in Java and explore some of the most common patterns.
Loops and control statements to print patterns in Java are best. The loops help you to repeat a block of code until a certain condition is met, and the control statements allow you to alter the flow of the program based on certain conditions. The different patterns in Java are discussed below:
We will deal with different types of Java Pattern Programs through the following docket.
Pattern Programs in Java
Star Patterns in Java
Star patterns are a popular pattern program in Java, often used to create interesting visual designs or graphics. These programs use asterisks or other symbols to create various shapes and patterns. Star patterns are commonly used in computer graphics, logo designs, and other visual displays.
Creating star patterns in Java involves using nested loops to control the number of rows and columns and the position of the asterisks or other symbols. The program can be customized to create patterns, including triangles, squares, circles, and more complex designs. Also, it can be customized to create a variety of patterns, as mentioned below: