Java Judgment palindrome Number sample sharing _java

Source: Internet
Author: User

To determine whether a number of palindrome examples, palindrome number is the original number and its inverted number is equal, such as: 123321, and then still 123321, that is, palindrome number

Copy Code code as follows:

/**
* To determine whether a number of palindrome number, palindrome number is the original number and the number of inverted after the equal
* such as: 123321, then still 123321, that is, palindrome number
* @author Lvpeiqiang
*/
public class Huiwenshu
{

public boolean ishuiwenshu (int num)
{
int s = 0;
int bnum = num;
int mod;

The following is the method of inverting the numerical 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 auto 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);
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.