//字母逆序
public static String letterReverse(String str) {
String str2 = "";
for (int i = str.length() - 1; i > -1; i--) {
str2 += String.valueOf(str.charAt(i));
}
return str2;
}
//单词逆序
public static String wordReverse(String str){
String str2 = "";
String[] s = str.split(" ");
for(int i = s.length - 1; i > -1; i--){
str2 += String.valueOf(s[i]) + " ";
}
return str2;
}
网友评论