Monday, August 2, 2010

Article | Java To Check Whether a string is pallindrome or not

To Check Whether a string is pallindrome or not

import java.io.*;

class Pallindrome
{
public static void main(String args[])
{
String ch="";
int f=0;
System.out.print(" Enter A String : ");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
try
{
ch=br.readLine();
}catch(Exception e){}
int n=ch.length();
for(int i=0; i <(n/2) ; i++)
{
if(ch.charAt(i)==(ch.charAt(n-i-1)))
{
f=1;
break;
}
}
if(f==1)
System.out.println(" Is A Pallindrome ");
else
System.out.println(" Is Not A Pallindrome ");
}
}

Loading...

Comments :

1
 
Anonymous said...

Really helped me. Nice Post

September 8, 2010 at 7:30 PM  

Subscribe

Enter your email address:

Followers

Chicklets

My Zimbio