I have searched everywhere and I cannot figure out how to create this output using a nested for loop in java:
"a
ab
abc
abcd"
continued until z
this is what I have tried
String alphabet = "abcdefghijklmnopqrstuvwxyz";
for(int i = 0; i <= 25; i++)
{
for(char j = (char)(alphabet.charAt(i)); j<=i; j++)
{
System.out.print(j);
}
System.out.println();
}
Please help me!
Here you go !
Here is the answer:
The outer loop switches from one row to another whilst the inner loop prints the characters for that particular row.