✅ Reverse Left Half Pyramid
output: *****
****
***
**
*
Code: for (int i = n; i >= 1; i--) {
for (int j = 1; j <= n - i; j++){
[Link](" ");
}
for (int j = 1; j <= i; j++) {
[Link]("* ");
}
[Link]();
}
✅ Alphabet Pattern
output: A
AB
ABC
ABCD
ABCDE
Code: public class AlphabetPattern {
public static void main(String[] args) {
int n = 5;
for (int i = 1; i <= n; i++) {
char ch = 'A';
for (int j = 1; j <= i; j++) {
[Link](ch + " ");
ch++;
}
[Link]();
}
}
}
✅ Hollow Right-Angled Triangle
output: *
**
* *
* *
*****
Code: public class HollowRightTriangle {
public static void main(String[] args) {
int rows = 5;
for (int i = 1; i <= rows; i++) {
for (int j = 1; j <= i; j++) {
if (j == 1 || j == i || i == rows)
[Link]("* ");
else
[Link](" ");
}
[Link]();
}
}
}
✅Reverse Number Triangle
output: 54321
4321
321
21
1
Code: public class ReverseNumberTriangle
{
public static void main(String[] args)
{
int rows = 5;
for (int i = rows; i >= 1; i--) {
for (int j = i; j >= 1; j--) {
[Link](j + " ");
}
[Link]();
}
}
}
✅Mirror Number Triangle
output: 1
12
123
1234
12345
Code: public class MirrorNumberTriangle {
public static void main(String[] args) {
int rows = 5;
for (int i = 1; i <= rows; i++) {
for (int j = i; j < rows; j++)
[Link](" ");
for (int k = 1; k <= i; k++)
[Link](k + " ");
[Link]();
}
}
}
✅X Star Pattern
output: * *
* *
*
* *
* *
Code: public class XPattern {
public static void main(String[] args) {
int n = 5;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
if (j == i || j == (n - i + 1))
[Link]("*");
else
[Link](" ");
}
[Link]();
}
}
}