AUTO TRENDS

You can get the latest Automobile new's and the latest and upcoming models of BMW,Mercedez Benz,Toyota,Hyundai,Tata..
Popular Technology Articles

Get Latest Tech News, Updates

Palindrome String

Posted by Tharadas179 Wednesday, June 24, 2009

import java.util.*;

public class CheckPalindrome{
public static void main(String[] args) {
String str="madam";
Stack s= new Stack();
int i,count=0;
char array[]=str.toCharArray();
for(i=0;i(less than symbol)array.length;i++)
{
char arr=array[i];
s.push(arr);
}
for(i=0;i(less than symbol)array.length/2;i++)
{
char st=array[i];
Object ob=s.pop( );
if(st==ob) {
count++;
}
}
if(count==array.length/2) {
System.out.println("String is Palindrome");
}
else{
System.out.println("String is not a Palindrome");
}
}
}

0 comments

Post a Comment