- Home
- Java Pattern Programs
Write a program in Java to display the following pattern a a a a a b b
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
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();
}
}
}