class Hello {
public static void main(String[] args) {
String[] str = {"010","3223","666","7890987","123123"};
char[] ch;
for (int i = 0 ; i < str.length ; i++) {
ch = str[i].toCharArray();
boolean b = true;
for (int j = 0 ; j < ch.length/2 ; j++) {
if(ch[j] != ch[ch.length - 1 - j]) {
b = false;
break;
}
}
if (b) {
System.out.print(ch);
System.out.println("是对称的");
}else {
System.out.print(ch);
System.out.println("不是对称的");
}
}
}
} |