Skip to content

Commit 712be13

Browse files
committed
First Reverse
1 parent 91dfe67 commit 712be13

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/easy/FirstReverse.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package easy;
2+
3+
/**
4+
* Have the function FirstReverse(str) take the str parameter
5+
* being passed and return the string in reversed order.
6+
* For example: if the input string is "Hello World and Coders"
7+
* then your program should return the string sredoC dna dlroW olleH.
8+
*/
9+
public class FirstReverse {
10+
11+
/**
12+
* First Reverse function.
13+
*
14+
* @param str input string
15+
* @return reversed string
16+
*/
17+
private static String firstReverse(String str) {
18+
return new StringBuilder(str).reverse().toString();
19+
}
20+
21+
/**
22+
* Entry point.
23+
*
24+
* @param args command line arguments
25+
*/
26+
public static void main(String[] args) {
27+
var result1 = firstReverse("Hello World and Coders");
28+
System.out.println(result1);
29+
var result2 = firstReverse("Good Looking Blues");
30+
System.out.println(result2);
31+
}
32+
33+
}

0 commit comments

Comments
 (0)