Saturday, 1 December 2012

Palindrome_string


import java.io.*;
class Palindrome
{
public static void main(String args[])throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int i,l;
String s,k="";
System.out.println("Enter the string");
s=br.readLine();
l=s.length();
for(i=l-1;i>=0;i--)
{
k=k+s.charAt(i);
}
if(s.compareTo(k)==0)
{
System.out.println("The string is palindrome");
}
else
{
System.out.println("The string is not palindrome");
}
}
}

No comments:

Post a Comment