import java.io.*;
class Palindrome
{
public static void main(String arr[])
{
String s1="",s2="";
int len=0,first=0,last=0,flag=0;
System.out.println("Enter The String..");
try
{
DataInputStream dis=new DataInputStream(System.in);
s1=dis.readLine();
}
catch(Exception e){}
len=s1.length();
System.out.println("Length is "+len);
first=0;
last=len-1;
while(first
{
if(s1.charAt(first)==s1.charAt(last))
{
flag=1;
}
else
{
flag=0;
}
first++;
last--;
}
if(flag==1)
{
System.out.println("Palindrome");
}
else
{
System.out.println("Not Palindrome");
}
}
}
No comments:
Post a Comment