String message =
"he saw a racecar"
;
StringBuilder rev =
new
StringBuilder();
for
(
int
i = message.length()-
1
; i >=
0
; i--) rev.append(message.charAt(i));
System.out.println(rev.toString());
将一个字符串逆序,不要使用反转函数
时间: 2024-11-08 12:23:44
String message =
"he saw a racecar"
;
StringBuilder rev =
new
StringBuilder();
for
(
int
i = message.length()-
1
; i >=
0
; i--) rev.append(message.charAt(i));
System.out.println(rev.toString());
将一个字符串逆序,不要使用反转函数