题解 | #反转字符串#
反转字符串
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[] chArr = str.toCharArray(); for(int i = 0, j = chArr.length-1;i<j;i++,j--){ char temp = chArr[i]; chArr[i] = chArr[j]; chArr[j] = temp; } return new String(chArr); } }