This repository contains a collection of Java programs designed to print various star (*)
patterns to the console. These exercises are excellent for practicing and understanding fundamental programming concepts like nested loops, conditional logic, and user input handling in Java.
This collection features a wide variety of patterns, from simple geometric shapes to more complex artistic designs. All pattern programs are located within the Star Patterns/
directory.
- Square & Hollow Square
- Hollow Rectangle
- Right Triangle & Inverted Right Triangle
- Mirrored Right Triangle & Inverted Mirrored Right Triangle
- Pyramid & Hollow Pyramid
- Inverted Pyramid & Hollow Inverted Pyramid
- Diamond & Hollow Diamond
- Hourglass
- Cross & Plus Sign
- Butterfly & Hollow Butterfly
- Heart
- Christmas Tree
- Right Pascal's Triangle & Left Pascal's Triangle
- Double Hill
- Diamond In a Box
- Spiral
- Wave
- ZigZag
- Letter A
- Letter Z
Each pattern is a standalone Java program. It prompts the user for a size parameter (like the number of rows) and then generates the corresponding pattern.
-
Clone the Repository
git clone https://github.com/MrCoder240/java_pattern_series.git cd java_pattern_series
-
Navigate to the Directory All the source files are in the
Star Patterns
directory.cd "Star Patterns"
-
Compile a Pattern Use the Java compiler (
javac
) to compile the.java
file of the pattern you want to see. For example, to compile thePyramid.java
file:javac Pyramid.java
-
Run the Program Use the
java
command to execute the compiled class. The program will then prompt you for input.java Pyramid
Example Interaction:
Enter the number of rows: 5 * *** ***** ******* *********
You can repeat the compile
and run
steps for any other pattern file in the directory.