题解 | #字符逆序#
字符逆序
http://www.nowcoder.com/practice/cc57022cb4194697ac30bcb566aeb47b
要对String的内置char[]数组有深刻理解。反过来排序,for循环效率最高
import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner in = new Scanner(System.in); while(in.hasNextLine()){ String li = in.nextLine(); char[] liArr = li.toCharArray(); int len = liArr.length; StringBuilder builder = new StringBuilder(); for(int i=0;i<len;i++){ builder.append(liArr[len-i-1]); } System.out.println(builder); } } }