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 :
Post a Comment