fix: ReversedString

This commit is contained in:
2024-11-16 13:51:40 -05:00
parent 47bab72ff3
commit b79fe73ffb
3 changed files with 46 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
import java.util.Scanner;
/**
* ReversedString
*/
public class ReversedString {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Please enter your String:");
String str = sc.nextLine();
System.out.println(revSTR(str));
}
private static String revSTR(String str) {
String revString = "";
for (int i = str.length() - 1; i >= 0; i--) {
char temp = str.charAt(i);
revString += temp;
}
return revString;
}
}