将一个字符串倒叙输出
public class Test2 {
public static void main(String[] args) {
String str = "love";
System.out.println(daoxu(str));
}
public static String daoxu(String str) {
char[] arr = str.toCharArray();
for (int i = 0, j = arr.length - 1; i < j; i++, j--) {
char temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
return new String(arr);
}
}