The example aims to check if the number is a palindrome number or not in Java.
Source Code
package com.beginner.examples;
public class PalindromeExample {
public static void main(String[] args){
int num = 2019;
int m = num;
int reNum = 0;
int n = 0;
//reverse the number
while(m > 0){
// modulus
n = m % 10;
m = m / 10;
reNum = reNum * 10 + n;
}
if(num == reNum)
System.out.println(num + " is a palindrome number.");
else
System.out.println(num + " is not a palindrome number.");
}
}
Output:
2019 is not a palindrome number.