例:
如ABCBA或ABDDBa 返回true
Abcc返回false
import java.util.Scanner;
public class Test06 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
int capital=0,lowercase=0,other=0;
System.out.println("请输入一行字符串");
String str = sc.nextLine();
System.out.println(check(str.toUpperCase())); //将输入的字符全转为大写字母
}
public static boolean check(String t) {
for (int i = 0; i < t.length() / 2; i++) {
if (t.charAt(i) != t.charAt(t.length() - i - 1)) {
return false;
}
}
return true;
}
}