We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b47cafa commit d29f62dCopy full SHA for d29f62d
src/ReverseString.java
@@ -0,0 +1,22 @@
1
+public class ReverseString {
2
+
3
+ public static void main(String[] args) {
4
5
+ String str = "789";
6
+ System.out.println(reverseString(str));
7
+ }
8
9
+ public static String reverseString(String in) {
10
+ if (in == null)
11
+ throw new IllegalArgumentException("input null");
12
13
+ StringBuilder out = new StringBuilder();
14
15
+ char[] chars = in.toCharArray();
16
17
+ for (int i = chars.length - 1; i >= 0; i--)
18
+ out.append(chars[i]);
19
20
+ return out.toString();
21
22
+}
0 commit comments