你应该是if判断语句加错地方了,下面是我自己写的答案,你可以比对一下...
public class Test {
public static void main(String[] args) {
String [] arr={"12321","445544","123456","12021"};
int count = 0;
a:for (String string : arr) {
char[] chs = string.toCharArray();
for (int i = 0; i < chs.length/2; i++) {
if(chs!=chs[chs.length-1-i]){
continue a;
}
}
count++;
System.out.println(string);
}
System.out.println("个数为:"+count);
}
} |