import java.util.Scanner;
class Student
{
public static void main(String args[])
{
char s[]=new char[10];
int i,j,flag=1,len;
System.out.println("enter ur string and integer");
Scanner src=new Scanner(System.in);
String name = src.next();
s=name.toCharArray();
int length=s.length;
for(i = 0,j=length-1; i<length; i++, j--)
{
if(s[i]!=s[j])
{
flag=0;
break;
}
}
if(flag!=0)
{
//if flag is true.
System.out.println("it is a palindrome");
}
else
System.out.println("it is not a
palindrome");
}
}
Sample output:
run:
enter ur string and integer
heera
it is not a palindrome