Java Palindrome Number Program

 

Program to find that the given number is Palindrome or not.

/**
 * This program is used to find that given number is Palindrome or not.
 * @author W3schools360
 */
public class PalindromeNumber {
      static void palindrome(int num){
            int newNum = 0, reminder, temp;
            temp = num;
            //Reverse the digit's of the number.
            while(temp != 0){
                  reminder = temp
                  newNum = newNum*10 + reminder;
                  temp = temp/10;
            }
            //Check if reverse of all digit's of the number
            //is equal to the given number or not.
            if(newNum == num){
                  System.out.println(num +" is palindrome.");
            }else{
                  System.out.println(num +" is not palindrome.");
            }
      }    

      public static void main(String args[]){
            //method call
            palindrome(12321);
      }
}

Output

12321 is palindrome.