mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-25 21:44:07 +08:00
@ -9,12 +9,11 @@ public class ReverseStringRecursive {
|
||||
* @param str string to be reversed
|
||||
* @return reversed string
|
||||
*/
|
||||
public static String reverse(String str)
|
||||
{
|
||||
if(str.isEmpty()){
|
||||
public static String reverse(String str) {
|
||||
if (str.isEmpty()) {
|
||||
return str;
|
||||
} else {
|
||||
return reverse(str.substring(1))+str.charAt(0);
|
||||
return reverse(str.substring(1)) + str.charAt(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user