标签:
Write a function that takes a string as input and returns the string reversed.
Example:
Given s = "hello", return "olleh".
public class Solution {
public String reverseString(String s) {
StringBuffer sb = new StringBuffer();
int n = s.length();
for(int i = n-1;i >= 0;i--){
sb.append(s.charAt(i));
}
return sb.toString();
}
}
标签:
原文地址:http://blog.csdn.net/lpjishu/article/details/51227030