判断是否为回文字符串?
public static boolean judge (String str) {
// write code here
if(str.equals(""))
return true;
str = str.toLowerCase();
int start = 0;
int end = str.length()-1;
while(start<end) {
while(!(str.charAt(start)>='a'&&str.charAt(start)<='z')||str.charAt(start)<='9'&&str.charAt(start)>='0') {
start++;
}
while(!(str.charAt(end)>='a'&&str.charAt(end)<='z')||str.charAt(end)<='9'&&str.charAt(end)>='0') {
end--;
}
if(str.charAt(start)!=str.charAt(end))
return false;
start++;
end--;
}
return true;
}
}