Skip to content

Commit

Permalink
Merge pull request #68 from tim-w97/string_reverse
Browse files Browse the repository at this point in the history
added a function to reverse a string
  • Loading branch information
ademclk authored Aug 28, 2022
2 parents 9e9e6b8 + ff03e12 commit 82603c7
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 82603c7

Please sign in to comment.