This commit is contained in:
nik
2026-05-20 16:20:45 -07:00
commit 007710b5a8
91 changed files with 450401 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
public class ReverseString {
public static void main(String[] args){
System.out.println(reverse("Hello"));
System.out.println(reverse("nathan"));
System.out.println(reverse("racecar"));
System.out.println(reverse("taco"));
System.out.println(reverse("ABBA"));
System.out.println(reverse(""));
System.out.println(reverse("a"));
}
public static String reverse(String str){
if (str.isEmpty()) {
return "";
} else if (str.length() == 1) {
return str;
}
String backwards = reverse(str.substring(1)) + str.charAt(0);
return backwards;
}
}