Palindrome checker in Java