KnowledgeBoat Logo

Java Pattern Programs

Write a program in Java to display the following pattern:

a a a a a
b b b b b
A A A A A
B B B B B

Java

Java Library Classes

ICSE

51 Likes

Answer

public class KboatPattern
{
    public static void main(String args[]) {
        int a = 97;
        for (int i = 1; i <= 4; i++) {
            for (int j = 1; j <= 5; j++) {
                System.out.print((char)a + " ");
            }
            a++;
            if (i == 2)
                a = 65;
            System.out.println();
        }
    }
}

Output

BlueJ output of Write a program in Java to display the following pattern: a a a a a b b b b b A A A A A B B B B B

Answered By

24 Likes