Sunday, September 2, 2012

Palindrome Number program in JAVA

Easy and Simple program to check for a number to be a palindrome number, in Java.

public class Palindrome
{
 public static void main(String arg[])
 {
  if (arg.length!=1)
  {
   System.out.println("1 Argument Required..");
   return;
  }
               
                int no=Integer.parseInt(arg[0]);
                int no2=0,x=no;
                while(no>0)
                {
   no2=(no2*10)+(no%10);
   no=no/10;
                }
                System.out.println("\nOriginal No. : " + x);
                System.out.println("Reversed No. : " + no2 + "\n");
                if(x==no2)
   System.out.println(x + " is Palindrome..");
                else
   System.out.println(x + "is not Palindrome..");
 }
}


EmoticonEmoticon