[java] Java way to check if a string is palindrome