public class Test08 {
public static void main(String[] args) {
@SuppressWarnings("resource")
Scanner input = new Scanner(System.in);
System.out.print("请判断该数字是否是回文数字: ");
long num = input.nextLong();
System.out.print("该数字是否是回文数字?: " + ifPalindromicNumber(num));
}
public static long palindromicNumber (long num) {
long temp = 0;
while (num != 0) {
temp *= 10;
temp += num % 10;
num /= 10;
}
return temp;
}
public static boolean ifPalindromicNumber (long num) {
long temp = palindromicNumber (num);
if (temp == num) {
return true;
} else {
return false;
}
}
}