[Go to site: main page, start]

0% found this document useful (0 votes)
6 views3 pages

Java Patterns Code Output

The document provides Java code examples for creating various patterns, including a solid square, a right triangle, and a pyramid star. Each pattern is accompanied by its corresponding output. The code snippets demonstrate basic loops and printing techniques in Java.

Uploaded by

james842007
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)
6 views3 pages

Java Patterns Code Output

The document provides Java code examples for creating various patterns, including a solid square, a right triangle, and a pyramid star. Each pattern is accompanied by its corresponding output. The code snippets demonstrate basic loops and printing techniques in Java.

Uploaded by

james842007
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

Java Pattern Programs (Code & Output)

Pattern 1 – Solid Square

Java Code Output


public class Pattern1 { public static void ***** ***** ***** ***** *****
main(String[] args) { int n = 5; for (int i
= 1; i <= n; i++) { for (int j = 1; j <= n;
j++) { [Link]("*"); }
[Link](); } } }
Pattern 2 – Right Triangle

Java Code Output


public class Pattern2 { public static void * ** *** **** *****
main(String[] args) { int n = 5; for (int i
= 1; i <= n; i++) { for (int j = 1; j <= i;
j++) { [Link]("*"); }
[Link](); } } }
Pattern 5 – Pyramid Star

Java Code Output


public class Pattern5 { public static void * *** ***** ******* *********
main(String[] args) { int n = 5; for (int i
= 1; i <= n; i++) { for (int j = 1; j <= n
- i; j++) { [Link](" "); } for
(int j = 1; j <= (2 * i - 1); j++) {
[Link]("*"); }
[Link](); } } }

You might also like