package 回文; public class yhisHuiWen {
public static void ishuiwen(String arr[]){ boolean flag=true;//标志位
for(int i=0;i<arr.length;i++){
StringBuilder sb=new StringBuilder(arr[i]);
String s=sb.reverse().toString();//翻转
for(int j=0;j<s.length();j++){
if(s.charAt(j)!=arr[i].charAt(j)){ //有一个不为回文就指标值位为false
flag=false;
break;
}
}
}
if(!flag){
System.out.println("-1");
}
else System.out.println("1");
} public static void main(String[] args) {
String arr[]={"aba","hhssaasshh","hellolleh"};
ishuiwen(arr);
}
}