//方法一
String originalString = "abcdefg";
StringBuffer stringBuffer = new StringBuffer(originalString);
System.out.println(stringBuffer.reverse());
//方法二
String originalString = "abcdefg";
String resultString = "";
char[] charArray = originalString.toCharArray();
for (int i = charArray.length-1; i>=0; i--){
resultString +=charArray;
}
System.out.println(resultString);
}
|