Write a java program to display each String in reverse order from a String array.
import java.io.*;
public class ReverseStringArray {
public static void
main(String[] args) {
// Sample array
of strings
String[] stringArray = {"Hello",
"World"};
// Iterate
through the array and reverse each string
for (String
originalString : stringArray) {
String
reversedString = new StringBuilder(originalString).reverse().toString();
System.out.println("Original: " + originalString + "
Reversed: " + reversedString);
}
}
}
C:\Program Files\Java\jdk-11.0.17\bin>javac
ReverseStringArray.java
C:\Program Files\Java\jdk-11.0.17\bin>java ReverseStringArray
Original: Hello Reversed: olleH
Original: World Reversed: dlroW
C:\Program Files\Java\jdk-11.0.17\bin>