回文字符串

public class HuiWenTest3 {
/**
 * @SERLIN
 */
public static void main(String[] args) {
System.out.println("请输入一个字符串");
Scanner input = new Scanner(System.in);
String str = input.next();
int count = 0;
for (int i = 0; i < str.length() / 2; i++) {
if ((str.substring(i, i + 1)).equals(str.substring(str.length() - 1- i, str.length() - i))) {
count++;
}
}
if (count == str.length() / 2) {
System.out.println("是回文字符串");
}else{
System.out.println("不是回文字符串");
}
}
}

原文地址:https://www.cnblogs.com/xiatian21/p/11587197.html