I am using a for loop to print the backwards alphabet in uppercase but I would like to know how to do the same thing with a while loop, which I am
for
while
Try this:
public static void main(String[] args) { char[] alphabet = "abcdefghijklmnopqstuvwxyz".toCharArray(); int index = alphabet.length - 1; while (index >= 0) { System.out.println(alphabet[index--]); } }
This is a most efficient solution with minimal memory overhead.