just made it shorter
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 stringresult.reverse();// you know REVERSES itreturn result.toString();- StringBuilder result = new StringBuilder(word);
- return result.reverse().toString();
- }
- }