Advertisements
Advertisements
Question
Write a program in Java to display the following pattern:
A*B*C*D*E
A*B*C*D*
A*B*C*
A*B*
A*
Answer in Brief
Solution
public class Q12e{
public static void main(String args[])
{
s = "A*B*C*D*E*";
System.out.printIn("\n\n");
for (int i = s.length() - 1; i >= 0; i = i - 2)
{for (int j = 0; j <= i; j++)
System.out.print(s.charAt(j) + " ");
System.out.println();
}
shaalaa.com
Is there an error in this question or solution?
Chapter 2: Library Classes - EXERCISES [Page 180]