题解 | #反转字符串#
反转字符串
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[] chars = str.toCharArray();
int len = str.length();
for (int i = 0; i < len; i++){
chars[i] = str.charAt(len - i -1);
}
return new String(chars);
}
}
查看9道真题和解析

