Here's a solution.

private static void reverseRecursively(char[] myCharArr, int next) {
    if (next >= myCharArr.length)
        return;

    // use recusion BEFORE printing in order to print in reversed order
    reverseRecursively(myCharArr, next+1); 
    System.out.println(myCharArr[next]);
}

First call to the method should use 0 for the "next" index:

    reverseRecursively(myCharArr, 0);
Answer from ArneHugo on Stack Overflow
🌐
Medium
medium.com › @jasonwei_613 › java-reverse-string-recursion-f3dcaa3d90e2
Java Reverse String (Recursion). How do you use Recursion to reverse an… | by Jason Wei | Medium
May 21, 2019 - The most important thing for solving anything is to understand what you need to solve. In this case is to reverse the items in the given character array using recursion.
🌐
Techie Delight
techiedelight.com › home › java › recursive solution to reverse a string in java
Recursive solution to reverse a String in Java | Techie Delight
1 week ago - There are several ways to reverse a string using recursion in Java: The idea here is to first convert the given string into a character array, reverse the character array recursively, and finally convert the character ...
🌐
Squash
squash.io › how-to-reverse-a-string-in-java
How to Reverse a String in Java - Squash.io
- Using recursion: You can also reverse a string recursively by recursively calling a method to reverse the substring excluding the first character and then appending the first character at the end.
🌐
CodeGym
codegym.cc › java blog › random › different ways to reverse a string in java
Different Ways to Reverse a String in Java
February 1, 2023 - The third method is using recursion, where we call a recursive function and solve the problem by concatenating the first character of the string with the reversed substring of the remaining characters. The fourth method is by using an array to reverse a string in java.
Top answer
1 of 16
104

The function takes the first character of a String - str.charAt(0) - puts it at the end and then calls itself - reverse() - on the remainder - str.substring(1), adding these two things together to get its result - reverse(str.substring(1)) + str.charAt(0)

When the passed in String is one character or less and so there will be no remainder left - when str.length() <= 1) - it stops calling itself recursively and just returns the String passed in.

So it runs as follows:

reverse("Hello")
(reverse("ello")) + "H"
((reverse("llo")) + "e") + "H"
(((reverse("lo")) + "l") + "e") + "H"
((((reverse("o")) + "l") + "l") + "e") + "H"
(((("o") + "l") + "l") + "e") + "H"
"olleH"
2 of 16
20

You need to remember that you won't have just one call - you'll have nested calls. So when the "most highly nested" call returns immediately (when it finds just "o"), the next level up will take str.charAt(0) - where str is "lo" at that point. So that will return "ol".

Then the next level will receive "ol", execute str.charAt(0) for its value of str (which is "llo"), returning "oll" to the next level out.

Then the next level will receive the "oll" from its recursive call, execute str.charAt(0) for its value of str (which is "ello"), returning "olle" to the next level out.

Then the final level will receive the "oll" from its recursive call, execute str.charAt(0) for its value of str (which is "hello"), returning "olleh" to the original caller.

It may make sense to think of the stack as you go:

// Most deeply nested call first...
reverse("o") -> returns "o"
reverse("lo") -> adds 'l', returns "ol" 
reverse("llo") -> adds 'l', returns "oll" 
reverse("ello") -> adds 'e', returns "olle" 
reverse("hello") -> adds 'h', returns "olleh" 
Find elsewhere
🌐
JavaBeat
javabeat.net › home › how to reverse a string in java?
How to Reverse a String in Java?
January 31, 2024 - The CharArray is then printed using the reverse iteration. By using the following line of code, import the necessary dependencies and classes from the “java.util” package: ... The string variable “str” is initialized with the following values. The character array “reverseString” stores the string in the form of characters which is returned by the toCharArray().
🌐
Emeritus
emeritus.org › home › blog › information technology › 9 most convenient ways to reverse a string in java
9 Most Convenient Ways to Reverse a String in Java
September 24, 2024 - The substring excludes the first character of the original string and concatenates the same at the end of the reversed string. The periodic recursive calls continue until the reversed substring is generated. ALSO READ: Java Programming Language Explained: Everything You Need to Know · To reverse a string using the byte array method, you need to first convert the input string into a byte array using the ‘getBytes()’ method.
🌐
Software Testing Help
softwaretestinghelp.com › home › java › how to reverse an array in java: 3 methods with examples
How to Reverse An Array In Java: 3 Methods With Examples
February 23, 2026 - Here we have used a character array as an example. Using the reverse function, we reverse the array elements one by one and then display the reversed array.
🌐
How to do in Java
howtodoinjava.com › home › string › reverse all characters of a string in java
Reverse All Characters of a String in Java
January 10, 2023 - Take the first character and append it to the last of the string · Perform the above operation, recursively, until the string ends · public class ReverseString { public static void main(String[] args) { String blogName = "How To Do In Java"; ...
🌐
Interviewing.io
interviewing.io › questions › reverse-string
How to Reverse a String [Interview Question + Solution]
September 13, 2018 - In the end, we convert the character array to a string and return it. Convert the string to a character array char_array. Call the recursive function reverseStringHelper with char_array, 0 and char_array.length - 1 as input.
🌐
Quora
quora.com › How-do-I-reverse-a-char-sequence-by-one-recursive-function-void-char-str-without-using-string-and-loops
How to reverse a char sequence by one recursive function void (char* str) without using string and loops - Quora
Answer (1 of 3): Without some additional state that seems impossible, the only thing you could do is to advance to the end of the string recursively.. If you allow global vars, you can count while going to the end, and on the way back the recursion stack you could swap chars.
🌐
Upgrad
upgrad.com › home › tutorials › software & tech › reverse an array in java
Comprehensive Guide to Reversing an Array in Java
April 1, 2025 - A: You can apply the same two-pointer or recursive logic, but instead of starting at the very beginning, start at the index where you want to begin reversing and stop at the index where you want to end.
🌐
Javatpoint
javatpoint.com › reverse-string-using-array-in-java
Reverse String Using Array in Java - Javatpoint
Reverse String Using Array in Java with java tutorial, features, history, variables, programs, operators, oops concept, array, string, map, math, methods, examples etc.
🌐
The Knowledge Academy
theknowledgeacademy.com › blog › reverse-a-string-in-java
Reverse a String in Java? - A Complete Guide
May 14, 2026 - To reverse a String using a stack in Java, first, the character array should be converted into a String. Then, each character of the array should be pushed into the stack. The popped characters from the stack should be added to StringBuilder.