要求实现字符逆序。
解析:
String str = "ABC123ABC";StringBuilder stringBuilder = new StringBuilder(str); stringBuilder.reverse();String newStr = stringBuilder.toString();System.out.println("反转前:" + str); System.out.println("反转后:" + newStr);String str = "ABC123ABC";char[] charArray = str.toCharArray(); Stackstack = new Stack<>(); StringBuilder newStr = new StringBuilder();for (char item : charArray) {stack.push(item); }for (int i = 0; i < charArray.length; i++) {newStr.append(stack.pop()); }System.out.println("反转前:" + str); System.out.println("反转后:" + newStr.toString());
上一篇:jsp80210车辆保险车险管理系统ssm+mysql
下一篇:BASNet调研