题意:
Write a function that takes a string as input and returns the string reversed.
Example:
Given s = "hello", return "olleh".
就是将一个字符串翻转输出。
public String reverseString(String s) { if(s == null || s.length() < 2) return s; char[] chars = s.toCharArray(); for(int i=0; i<chars.length / 2; i++){ char temp = chars[chars.length - 1 - i]; chars[chars.length - 1 - i] = chars[i]; chars[i] = temp; } return new String(chars); }