Wednesday, January 16, 2008

Palindrom String

Check a String is palindrom or not

import java.io.*;
class palindrom
{
public static void main(String args[])throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println(" Enter a String ");
String s = br.readLine();
int l=s.length();
String x = "";
int ch;
ch=0;
for(int i=l-1;i>=0;i--)
{
x=x+s.charAt(i);
}
if(x.compareTo(s)==0)
System.out.println(" its A palindrom");
else
System.out.println(" its not a palindrom ");
}
}

No comments: