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

36 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();
        }
    }
}

Variable Description Table

Program Explanation

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

12 Likes