class Main {
var result = "";
for (var i = 0; i < str.length(); i++) {
result = str.charAt(i) + result;
}
return result;
}
public static void main
(String[] args
) { System.
out.
println(Main.
reverseString("Hello world")); // => dlrow olleH }
}
Y2xhc3MgTWFpbiB7CiAgcHVibGljIHN0YXRpYyBTdHJpbmcgcmV2ZXJzZVN0cmluZyhTdHJpbmcgc3RyKSB7CiAgICB2YXIgcmVzdWx0ID0gIiI7CiAgICBmb3IgKHZhciBpID0gMDsgaSA8IHN0ci5sZW5ndGgoKTsgaSsrKSB7CiAgICAgICAgcmVzdWx0ID0gc3RyLmNoYXJBdChpKSArIHJlc3VsdDsKICAgIH0KCiAgICByZXR1cm4gcmVzdWx0OwogIH0KICAKICBwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmdbXSBhcmdzKSB7CiAgICBTeXN0ZW0ub3V0LnByaW50bG4oTWFpbi5yZXZlcnNlU3RyaW5nKCJIZWxsbyB3b3JsZCIpKTsgLy8gPT4gZGxyb3cgb2xsZUgKICB9Cn0=