Java palindrome checker

What is palindrome ?
-Palindrome is a word or sequence that reads the same backwards as forwards.


For example :
MADAM

***************************************************************
COMPLETE SOURCE CODE FOR : JavaPalindromeChecker.java
***************************************************************


import java.util.Scanner;
import java.util.StringTokenizer;

public class JavaPalindromeChecker
{
public static void main(String[]args)
{
System.out.println("Put your text below");
Scanner sc=new Scanner(System.in);
String a=sc.nextLine();
StringTokenizer st=new StringTokenizer(a);
String b="";
while(st.hasMoreTokens())
{
b=b+st.nextToken();
}
int stringLength=b.length();
String benchMark="Palindrome";
if(stringLength%2!=0)
{
int c=((stringLength-1)/2);
for(int i=0;i<c;i++)
{
char before=b.charAt(c-(i+1));
char after=b.charAt(c+(i+1));
if(before!=after)
{
benchMark=new String("Not Palindrome");
}
}
}
else
{
int c=stringLength/2;
for(int i=0;i<c;i++)
{
char before=b.charAt(i);
char after=b.charAt(stringLength-(i+1));
if(before!=after)
{
benchMark=new String("Not Palindrome");
}
}
}
System.out.println(benchMark);
}
}


***************************************************************
JUST COMPILE AND EXECUTE IT
***************************************************************
Related Posts Plugin for WordPress, Blogger...

I Also Can Create T-Shirt Logo For You