Skip to content

Latest commit

 

History

History
55 lines (38 loc) · 1.85 KB

File metadata and controls

55 lines (38 loc) · 1.85 KB

Java Pattern Printing Collection

This repository contains a set of simple Java programs that demonstrate how to print various patterns using loops and basic logic. The code is grouped into three categories: character patterns, number patterns, and star patterns.

📁 Directory Structure

  • Character Patterns/

    • Programs that print patterns using letters (A, B, C, ...).
    • Example: pattern1.java prints a triangle of increasing alphabets.
  • Number Patterns/

    • Programs using digits (1, 2, 3, ...).
    • Each file corresponds to a different pattern (triangles, pyramids, matrices, etc.).
  • Star Patterns/

    • Patterns made with the asterisk (*) character.
    • Common exercises include pyramids, diamond shapes, and right/left aligned triangles.

Each folder contains 12 example programs named pattern1.java through pattern12.java.

🚀 Usage

  1. Open any pattern file in your favorite Java IDE or a text editor.
  2. Compile using javac:
    javac pattern1.java
  3. Run the compiled class and provide an integer input (rows/size) when prompted:
    java pattern1
  4. Observe the printed pattern in the console.

All programs read a single integer from standard input which controls the size of the pattern.

📝 Adding New Patterns

  • Copy one of the existing files and update the logic to create a new pattern.
  • Maintain the same input strategy (read an integer from Scanner).
  • Use descriptive comments at the top to indicate what the pattern looks like.

📚 Learning Goals

These examples are ideal for beginners learning how to use:

  • for loops (nested loops)
  • Scanner for input
  • Basic control flow and character/number arithmetic
  • Console output formatting with System.out.print and println

Feel free to explore, modify, and extend these programs as you learn Java!


Created on Feb 20, 2026