Skip to content

Commit

Permalink
added a function to reverse a string
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-w97 committed Aug 28, 2022
1 parent 9e9e6b8 commit ff03e12
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions challenges/Java/string_reverse/StringReverse.java
Original file line number Diff line number Diff line change
@@ -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;
}
}

0 comments on commit ff03e12

Please sign in to comment.