Код: Выделить всё
import java.util.*;
import java.io.*;
class Main {
public static String FirstReverse(String str) {
char[] chars = str.toCharArray();
String ret = "";
for (int i = chars.length - 1; i >= 0; i--) {
ret += chars[i];
}
return ret;
}
public static void main (String[] args) {
// keep this function call here
Scanner s = new Scanner(System.in);
System.out.print(FirstReverse(s.nextLine()));
}
}
Код: Выделить всё
import java.util.*;
import java.io.*;
class Main {
public static String FirstReverse(String str) {
return new StringBuilder(str).reverse().toString();
}
public static void main (String[] args) {
// keep this function call here
Scanner s = new Scanner(System.in);
System.out.print(FirstReverse(s.nextLine()));
}
}
Подробнее здесь: https://stackoverflow.com/questions/584 ... -are-wrong