Checks whether a given String is a Palindrome or not
import java.util.*;
public class palindrome
{
public static void main(String a[])
{
System.out.println("Enter any string");
Scanner s=new Scanner(System.in);
String str=s.next();
for(int i=0,j=str.length()-1;i<=j;i++,j--)
{
if(str.charAt(i)==str.charAt(j));
else
{
System.out.println("Not Palindrome : "+str);
System.exit(1);
}
}
System.out.println("Palindrome : "+str);
}
}
public class palindrome
{
public static void main(String a[])
{
System.out.println("Enter any string");
Scanner s=new Scanner(System.in);
String str=s.next();
for(int i=0,j=str.length()-1;i<=j;i++,j--)
{
if(str.charAt(i)==str.charAt(j));
else
{
System.out.println("Not Palindrome : "+str);
System.exit(1);
}
}
System.out.println("Palindrome : "+str);
}
}