- Home
- Java Pattern Programs
Write a program in Java to display the following pattern:
Java Pattern Programs
Write a program in Java to display the following pattern:
12345
2345
345
45
5
45
345
2345
12345
Answer
public class KboatPattern
{
public static void main(String args[]) {
for (int i = 1; i <= 5; i++)
{
for (int j = i; j <= 5; j++) {
System.out.print(j);
}
System.out.println();
}
for (int k = 1; k <= 4; k++) {
for (int l = 5 - k; l <= 5; l++) {
System.out.print(l);
}
System.out.println();
}
}
}