fork download
  1. class Main {
  2. public static String reverseString(String str) {
  3. var result = "";
  4. for (var i = 0; i < str.length(); i++) {
  5. result = str.charAt(i) + result;
  6. }
  7.  
  8. return result;
  9. }
  10.  
  11. public static void main(String[] args) {
  12. System.out.println(Main.reverseString("Hello world")); // => dlrow olleH
  13. }
  14. }
Success #stdin #stdout 0.12s 57528KB
stdin
Standard input is empty
stdout
dlrow olleH