所以我试图让用户输入一个字符串,将其向后打印,然后比较新字符串以查看它是否是回文......它似乎不起作用,我不知道为什么。 ..
public static void main(String[] args) {
Scanner input = new Scanner (System.in);
System.out.print("Enter a word: ");
String word = input.next();
StringBuilder drow = new StringBuilder(word);
drow.reverse();
System.out.println(drow);
System.out.print(" ");
String X = drow.toString();
if (word == X) {
System.out.println("That word is a palindrome");
} else {
System.out.println("That word is not a palindrome");
}
感谢您对为什么这不起作用的任何帮助...