- Home
- Java Pattern Programs
Write a program to display the pattern A B C D E A B C D A A B C A B A
Java Pattern Programs
Write a program to display the pattern:
A B C D E
A B C D A
A B C A B
A B A B C
A A B C D
Answer
public class KboatStringPattern
{
public static void main(String args[]) {
String word = "ABCDE";
int len = word.length();
for (int i = 0; i < len; i++) {
for (int j = 0; j < len - i; j++) {
System.out.print(word.charAt(j));
}
for (int k = 0; k < i; k++) {
System.out.print(word.charAt(k));
}
System.out.println();
}
}
}