import java.util.Scanner;
public class palindrome {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String word = sc.next();
String org_word = word;
word = word.replace(" ","");
String reverse = "";
for (int i = word.length()-1; i >=0; i--) {
reverse += word.charAt(i);
}
boolean palindrome = true;
for (int i= 0; i < word.length(); i++){
if(word.charAt(i) != reverse.charAt(i)){
palindrome = false;
}
}
if (palindrome) {
System.out.println("Your word is a palindrome!");
}
else System.out.println("Your word is not a palindrome!");
}
}
If I put a Palindrome in my Program like "racecar" it does it correctly, but if I type "race car" with a space, it doesn't work. Neither does it when I start a word with a capital letter.