java - nested for loop for alphabet increment -
I have searched everywhere and how can I create this output in Java by using nested for loop:
"a
ab
abc
abcd"
until z
That's what I've tried.
string alphabet = "abcdefghijklmnopqrstuvwxyz";
for (int i = 0; i & lt; = 25; i ++) {for (char j = (char) (Alphabet.charAt (i)); j & Please help me! < / Div>
Here is the answer: {for (int i = 'a'; i & lt; = x; i ++) {System.out}
for (int x = 'a'; x & lt; = 'z'; x ++) print ((four) i);} system.out .println ();} The external loop switches from one line to another, while the internal loop prints the characters of that particular line.
Comments
Post a Comment