So when I'm running this code with any word, it is always returning false. The first String accepts the word, and then it's changed to lower case. Then I'm building a new String out of it to compare it to another string that is appended as the reverse of the original word. Am I not seeing something, or can you tell me what's wrong with it?
public class Palindromes
{
public static void main(String[] args)
{
int count = Integer.parseInt(args[0]);
for(int i = 1; i <= count; i++)
{
System.out.print(isPalindrome(args[i]) + " ");
}
}
public static boolean isPalindrome(String s)
{
String str = s.toLowerCase();
StringBuilder orig_str = new StringBuilder(str);
StringBuilder revStr = new StringBuilder();
for (int i = str.length()-1; i >= 0; i--)
{
revStr.append(orig_str.charAt(i));
}
boolean isPal = (revStr == orig_str);
return isPal;
}
}