Im trying to make a simple programm that compares if a number or word is a palindrome. Ive made the following code, but I dont get why my if statement doesnt work. If you print the results you can see the numbers or letters are the same but my if statement doesnt think so. Here is my code. Thanks :
import java.util.*;
public class myPalindromo
{
public static void main(String[] args)
{
// TODO Auto-generated method stub
String number;
ArrayList < String > myNumber = new ArrayList < String > ();
Scanner sn = new Scanner(System.in);
number= sn.nextLine();
for(int i = 0 ; i<number.length() ; i++)
{
myNumber.add(number.valueOf(number.charAt(i)));
}
for(int i = 0; i<myNumber.size(); i++)
{
System.out.println(myNumber.get(i)+"=="+myNumber.get((myNumber.size()-1)-i));
if(myNumber.get(i)== myNumber.get((myNumber.size()-1)-i))
System.out.println("palindrome");
else
System.out.println("not palindrome");
}
}
}