Example of determining whether a number is a palindrome number. The palindrome number means that the original number is equal to the inverted number, such as: 123321, and then it is still 123321, that is, the palindrome number
Title: A 5-digit number, determine whether it is a palindrome number. That is, 12321 is a palindrome number, the single digits are the same as ten thousand digits, and the ten digits are the same as thousands.
/*** Determine whether a number is a palindrome number. The palindrome number is the original number and the inverted number* For example: 123321, and then it is still 123321, that is, the palindrome number* @author lvpeiqiang*/public class HuiWenShu { public boolean isHuiWenShu(int num) { int s = 0; int bNum = num; int mod; //The following is a method to invert the value while(bNum != 0) { mod = bNum%10; //123%10 = 3 s = s*10 + mod; //s = 0*10+3 bNum = bNum/10; //bNum = 123/10=12(int automatic conversion) } boolean b = (s == num); return b; } public static void main(String[] args) { HuiWenShu p = new HuiWenShu(); boolean b = p.isHuiWenShu (123321); System.out.println(b); }}