diff --git a/challenges/Java/string_reverse/StringReverse.java b/challenges/Java/string_reverse/StringReverse.java new file mode 100644 index 0000000..e2613d4 --- /dev/null +++ b/challenges/Java/string_reverse/StringReverse.java @@ -0,0 +1,16 @@ +public class StringReverse { + public static void main(String[] args) { + String reversedExampleString = reverseString("Pflaumenkuchen"); + System.out.println(reversedExampleString); + } + + static String reverseString(String stringToReverse) { + String reversedString = ""; + + for (char letter : stringToReverse.toCharArray()) { + reversedString = letter + reversedString; + } + + return reversedString; + } +}