Palindrome program in Java.

Java Programming Java8Object Oriented Programming

Following is the required program.

Example

Live Demo

public class Tester {
   public static void main(String args[]) {
      int r, sum = 0, temp;
      int m = 454;
      int n = m;
      temp = n;
      while (n > 0) {
         r = n % 10;
         sum = (sum * 10) + r;
         n = n / 10;
     }
     if (temp == sum) {
        System.out.println(m + " is a palindrome number.");
     } else {
        System.out.println(m + "is not a palindrome number.");
     }
   }
}

Output

454 is a palindrome number.
raja
Published on 22-Apr-2018 22:38:15
Advertisements