1 String info = "上海自来水来自海上"; 2 for (int i = 0; i < info.length() / 2; i++) { 3 if (info.charAt(i) != info.charAt(info.length() - 1 - i)) 4 { 5 System.out.println("不是回文"); 6 return;// 方法返回 7 } 8 } 9 System.out.println("是回文");