About Me

My photo
Raipur, Chhattisgarh, India
Hi , I am Amit Thakur. I have worked as a QA Engineer for two years and as a Java Developer for one year in NIHILENT TECHNOLOGIES PVT. LTD., Pune.Currently I am working as DEAN (Research & Development) in Bhilai Institute of Technology, Raipur.

Monday, April 19, 2010

JAVA(String Palindrome)--------------------------

// String Palindrome


import java.io.*;

class Palindrome

{

public static void main(String arr[])

{

String s1="",s2="";

int len=0,first=0,last=0,flag=0;

System.out.println("Enter The String..");

try

{

DataInputStream dis=new DataInputStream(System.in);

s1=dis.readLine();

}

catch(Exception e){}

len=s1.length();

System.out.println("Length is "+len);



first=0;

last=len-1;

while(first

{

if(s1.charAt(first)==s1.charAt(last))

{

flag=1;



}

else

{

flag=0;

}

first++;

last--;

}

if(flag==1)

{

System.out.println("Palindrome");

}

else

{

System.out.println("Not Palindrome");

}



}

}

No comments: