题解 | #反转字符串#
反转字符串
http://www.nowcoder.com/practice/c3a6afee325e472386a1c4eb1ef987f3
import java.util.*; public class Solution { /** * 反转字符串 * @param str string字符串 * @return string字符串 */ public String solve (String str) { // write code here //将字符串转化为字符数组 char[] ch=str.toCharArray(); int n=str.length(); char[] res=new char[n]; for(int i=0;i<n;i++){ res[i]=ch[n-i-1]; } return String.valueOf(res); } }