Java code for different ways to check if a given string is a palindrome or not.