Ad

just made it shorter

Code
Diff
  • public class ReverseString {
      public static String reverseString(String word) {
        StringBuilder result = new StringBuilder(word);
        return result.reverse().toString();
        }
    }
    • public class ReverseString {
    • public static String reverseString(String word) {
    • StringBuilder result = new StringBuilder();
    • result.append(word);// adds the word to the string
    • result.reverse();// you know REVERSES it
    • return result.toString();
    • StringBuilder result = new StringBuilder(word);
    • return result.reverse().toString();
    • }
    • }