[導(dǎo)入]一個翻轉(zhuǎn)字符串的函數(shù)
翻轉(zhuǎn)字符串,即輸入:abcd,輸出:dcba,
public static String reerseStringByStringBuffer(String str){
StringBuffer result = new StringBuffer();
for(int i=0;i<str.length();i++){
result.append(str.substring(str.length()-1-i, str.length()-i));
}
return result.toString();
}
文章來源:http://huxiaofei590.blog.163.com/blog/static/3259612200791091630470
posted on 2007-10-10 09:17 ThinkInJava 閱讀(98) 評論(0) 編輯 收藏