Javatpoint Logo
Javatpoint Logo

Zig Zag Star and Number Pattern in Java

In the previous section, we have discussed different pattern programs in Java. In this section, we will create Java programs for zig zag star and number patterns.

Steps to Print Zig Zag Number Pattern

  1. Print one backward slash first then one forward slash and continue.
  2. Enter the total characters in a row and store it an integer variable say row.
  3. Enter the total number of zig zag lines and store it in an integer variable say count.
  4. To print Backward slash:
    • Take first for loop to print all the rows.
    • Take an inner loop to print the column values.
    • Then go on printing the numbers according to the iteration.
  5. To print forward slash:
    • Take first for loop to print all the rows.
    • Take inner loop to print the column values.
    • Then go on printing the numbers according to the iteration.

Let's implement the above steps in a Java program.

ZigZagNumberPattern.java

Output:

Zig Zag Star Number Pattern in Java

Zig Zag Star Pattern

ZigZagStarPattern.java

Output:

Zig Zag Star Number Pattern in Java





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA