描述:给我一个字符串,例如I love java,输出: java love I 方法一 public class StringReverse { public void swap(char[] arr, int begin, int end) { while(begin < end) { char temp = arr[begin]; arr[begin] = arr[end]; arr[end] = temp; begin++; end--; } } //I love java publ…
(1)通过StringBuilder的reverse()方法,速度最快: public class StringReverse { public static void main(String[] args) { String str="hello"; System.out.println(reverse(str)); } public static StringBuilder reverse(String str){ return new StringBuilder(str).rev…