Write a function that takes a string as input and returns the string reversed.
Example:
Given s = "hello", return "olleh".
即反转字符串,逆序遍历依次append到StringBuffer即可
一刷:
public String reverseString(String s) { StringBuffer sb=new StringBuffer(); for(int i=0;i<s.length();i++){ sb.append(s.charAt(s.length()-1-i)); } return sb.toString(); }