Write Java program to check whether the word is palindrome or not.
class Palindrome
{
public static void main(String args[])
{
String ow="MADAM";
String rw="";
int l=ow.length();
for(int i=l-1;i>=0;i--)
rw=rw+ow.charAt(i);
if(ow.compareTo(rw)==0)
System.out.print("Word is Palindrom");
else
System.out.print("Word is not Palindrom");
}
}
{
public static void main(String args[])
{
String ow="MADAM";
String rw="";
int l=ow.length();
for(int i=l-1;i>=0;i--)
rw=rw+ow.charAt(i);
if(ow.compareTo(rw)==0)
System.out.print("Word is Palindrom");
else
System.out.print("Word is not Palindrom");
}
}