Blogger

Delete comment from: Javarevisited

raj said...

String reversedString = "";
public void reverseString(String word){
int stringLength = word.length();

String lastChar = word.substring(stringLength-1,stringLength);
reversedString += lastChar;
if(word.length() != 1) {
String updatedString = word.substring(0, stringLength - 1);
reverseString(updatedString);
}
Log.d("ReverseStringRecursion",reversedString);

}

Mar 28, 2020, 4:21:45 PM


Posted to How to Reverse String in Java Using Iteration and Recursion - Example

Google apps
Main menu