题解 | #字符逆序#
字符逆序
https://www.nowcoder.com/practice/cc57022cb4194697ac30bcb566aeb47b
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); String str = in.nextLine(); System.out.println(reverse(str)); } public static String reverse(String str){ StringBuilder sb = new StringBuilder(); sb.append(str); return sb.reverse().toString(); } }
知识点:
StringBuilder 的 reverse 放法: 将 I am a students 转换成了
tneduts a ma I