JAVA hexadecimal conversion

Source: Internet
Author: User

Java's Integer encapsulation class Integer and Long provide the toString (int I, int radix) static method, which can convert any hexadecimal Integer to another hexadecimal Integer.

Example:

Public class Main {public static void main (String [] args) {int numOct = 0123; // statement of the octal digit, add 0 to the Front) int numTen = 8888; // declaration of decimal numbers int numHex = 0 xabcd; // declaration of hexadecimal numbers, prefixed with 0x and Zero x) // convert binary, octal, and hexadecimal proprietary method System. out. println ("October 0123 is replaced with binary:" + Integer. toBinaryString (numOct); System. out. println ("decimal 8888 to decimal:" + Integer. toString (numTen); System. out. println ("hexadecimal 0xabcd to hexadecimal:" + Integer. toHexString (numHex); // You can also replace any hexadecimal integer with another hexadecimal number System. out. println ("hexadecimal 0xabcd to hexadecimal:" + Integer. toString (numHex, 7 ));}}


This article is from the blog of "Italian suckling pig", please be sure to keep this source http://lovesisi.blog.51cto.com/6414433/1301214

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.