使用把字符串倒置的方法判断回文,输出yes或者no
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String str = "";
str = input.next();
StringBuffer sb = new StringBuffer(str);
sb.reverse();//倒置字符串
int count = 0;
for(int i = 0;i<str.length();i++)
{
if(str.charAt(i) == sb.charAt(i)) {
count++;
}
}
if(count == str.length()) {
System.out.println("Yes");
}
else {
System.out.println("No");
}
}
}