0% found this document useful (0 votes)
4 views

Patterns in Java

The document defines patterns in Java as reusable solutions to common programming problems, enhancing code readability and maintainability. It lists various types of patterns, including design and programming patterns, and provides numerous examples of star and number patterns to print, such as squares, pyramids, diamonds, and more. Each pattern serves as a template for solving specific layout challenges in Java programming.

Uploaded by

HARISH S ECE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Patterns in Java

The document defines patterns in Java as reusable solutions to common programming problems, enhancing code readability and maintainability. It lists various types of patterns, including design and programming patterns, and provides numerous examples of star and number patterns to print, such as squares, pyramids, diamonds, and more. Each pattern serves as a template for solving specific layout challenges in Java programming.

Uploaded by

HARISH S ECE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Patterns in Java

Define Pattern in Java:

In Java, a pattern refers to a reusable solution to a commonly occurring


problem in software design or programming. These patterns serve as a
blueprint or template that can be adapted to different scenarios,
improving code readability, scalability, and maintainability.

Type of patterns are you interested in?

● Design Patterns: For software architecture and problem-solving.


● Programming Patterns: For logical structuring and output
formatting.

Problems:
1. Print the following Square Pattern
*****
*****
*****
*****
*****

2. Print the following Right Angle star Pattern


*
**
***
****
*****
3. Print the following Pyramid Pattern
*
***
*****
*******
*********

4. Print the following Inverted Pyramid

*********
*******
*****
***
*
5. Print the following Rhombus

*****
*****
*****
*****
*****
6. Print the Following star pattern-single right arrow:
*
**
***
****
*****
******
*******
********
*********
**********
***********
***********
**********
*********
********
*******
******
*****
****
***
**
*

7. Print the following HOLLOW SQUARE Pattern:


*****
* *
* *
* *
*****
8. Print the following Cross Pattern
* *
* *
* *
**
*
**
* *
* *
* *

9. Print the following Hollow square with X pattern


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

10. Print the following Plus Pattern


*
*
*
*******
*
*
*
11. Print the following star pattern - double Right Arrow
* *
** **
*** ***
**** ****
***** *****
****** ******
******* *******
******** ********
******************
******************
******** ********
******* *******
****** ******
***** *****
**** ****
*** ***
** **
* *

12. Print the following Diamond pattern


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

13. Print the following Inner - Diamond pattern


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

14. Print the following Chess - Diamond pattern


10101010
01010101
10101010
01010101
10101010
01010101
10101010
01010101
15. Print the following pattern with Alternate rows of 1’s and 0’s
111111
000000
111111
000000
111111
000000

16. Print the Box filled with 1's and 0's forming a plus sign If the
Input is even,reduce it to one number down. Eg: If the input is 10,
make it as 9.

111101111
111101111
111101111
111101111
000000000
111101111
111101111
111101111
111101111

17. Print the following patern


A
AB
ABC
ABCD
ABCDE
ABCDEF
18. Print the following patern

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

19. Print the following patern

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

20. Print the Zig - Zag Pattern:


* *
* * * *
* * *
21. Print the spiral matrix pattern:
1 2 3 4
12 13 14 5
11 16 15 6
10 9 8 7

22. Print the Pascal Triangle Number pattern:


1
11
121
1331
14641

23. Print the Butterfly pattern:


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

24. Print the Number palindrome Pyramid:


1
121
12321
1234321

25. Print the Alphabet Palindrome Pattern


A
ABA
ABCBA
ABCDCBA

You might also like