KnowledgeBoat Logo

Java Pattern Programs

Write a program to display the pattern:

A B C D E
B C D E
C D E
D E
E

Java

Java String Handling

ICSE

28 Likes

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 = i; j < len; j++) {
                char ch = word.charAt(j);
                System.out.print(ch);
            }
            System.out.println();
        }
    }
}

Output

BlueJ output of Write a program to display the pattern: A B C D E B C D E C D E D E E

Answered By

11 Likes