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
There is a much simpler way to reverse a string in Java.
public class StringReversalExample { public static void main(String[] args) { String alphabet = "abcdefghijklmnopqstuvwxyz"; String reversedString = new StringBuilder(alphabet).reverse().toString(); System.out.println(reversedString); } }