Pages

Ads 468x60px

Monday, 17 December 2012

Palindrome



1.WAJP that checks whether a given string is a palindrome or not. Ex: MALAYALAM is a palindrome.
Program:                                  Download the palindrome program

   class Palindrom
    {
  
   String Str_rev(String val)
    {
      String temp=" ";
  for(int i=val.length();i>0;i--)

{
 
  temp=temp+val.charAt(i-1);
 }
return temp.trim();
}
public static void main(String args[])
{
  Palindrom obj=new Palindrom();
  String name=args[0].trim();
  String rev=obj.Str_rev(name);
if(rev.equals(name))
   System.out.println("Palindrom");
 else
   System.out.println("not Palindrom");  
  }
}

0 comments:

Post a Comment

 

Sample text

Sample Text

Sample Text