how to reverse a string words in java without using reverse function code example
Example 1: java string reverse
String rev = new StringBuilder("Your String").reverse().toString();
Example 2: reverse a string in java
public static String reverse(String str) {
char[] oldCharArray = str.toCharArray();
char[] newCharArray= new char[oldCharArray.length];
int currentChar = oldCharArray.length-1;
for (char c : oldCharArray) {
newCharArray[currentChar] = c;
currentChar--;
}
return new String(newCharArray);
}