Tutorialspoint examples

Learn java tutorial with examples for beginners online

Palindrome Number Program in Java


Program to find that given number is Palindrome or not.

 * This program is used to find that given number is Palindrome or not.
 * @author javawithease
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 % 10;
                  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.");
                  System.out.println(num +" is not palindrome.");
      public static void main(String args[]){
            //method call


12321 is palindrome.

Download this example.

Download tutorialspointexamples Android App
Copyright © 2018 Tutorialspoint examples DMCA.com Protection Status