-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReverseString.java
More file actions
36 lines (23 loc) · 802 Bytes
/
Copy pathReverseString.java
File metadata and controls
36 lines (23 loc) · 802 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import java.util.*;
//import java.io.*;
class Main {
public static String FirstReverse(String str) {
// code goes here
/* Note: In Java the return type of a function and the
parameter types being passed are defined, so this return
call must match the return type of the function.
You are free to modify the return type. */
int len = str.length() - 1;
String newStr = "";
while(len >= 0) {
newStr = newStr + (char) str.charAt(len--);
}
return newStr;
}
public static void main (String[] args) {
// keep this function call here
Scanner s = new Scanner(System.in);
System.out.print(FirstReverse(s.nextLine()));
s.close();
}
}