题解 | #字符串反转#
字符串反转
https://www.nowcoder.com/practice/e45e078701ab4e4cb49393ae30f1bb04
import java.util.*; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String input = scanner.nextLine(); boolean allLowerCase = true;//布尔值 for (char c : input.toCharArray()) { if (Character.isUpperCase(c)) {//判断c是否为大写 allLowerCase = false; break; } } if (allLowerCase) {//根据是否为大写以确定是否输出 StringBuilder reversed = new StringBuilder(input).reverse(); System.out.println(reversed.toString()); } scanner.close(); } }