需求:键盘录入一个字符串,利用代码将字符串反转。
import java.util.Scanner; public class Boke { public static void main(String[] args){ Scanner Sc = new Scanner(System.in); System.out.print("请输入一个字符串:"); String x =Sc.next(); String cout = ""; for (int i = x.length()-1; i >=0 ; i--) { char c =x.charAt(i); cout+=c; } System.out.print(cout); } }
标签:java,String,反转,System,Scanner,字符串,cout From: https://www.cnblogs.com/ayue6/p/17817638.html