What might be used in the Java race

Source: Internet
Author: User

The following part of the content is not original, the original author see also please understand ~

Large number

String s= "12345"; BigInteger c=biginteger.valueof (s);

Format output

System.out.printf ("%+8.3f\n", 3.14); "+" indicates that the output will be signed, positive +, negative-; 8.3f indicates the output floating point number, width is 8, the decimal point remains 3 valid System.out.printf ("%+-8.3f\n", 3.14);/"-" Indicates the left-aligned System.out.printf ("%08.3f\n", 3.14);//"0" 8-bit width of the auto-fill 0system.out.printf ("% (8.3f\n",-3.14);/"(" If it is negative, Auto Plus () System.out.printf ("%,f\n", 123456.78); "," the money represents the method, every three bits has a comma System.out.printf ("%x\n", 0x2a3b); Output 16 binary number System.out.printf ("% #x \ n", 0x2a3b);//output with 0x identification of 16 binary System.out.printf ("Boss: Your name is%s, age:%3d years, Salary:%,-7.2f\n", " Ajioy ", 21,36000.00); System.out.printf ("Boss: Your name%1 $ s, age:%2$ #x岁 \ n", "Ajioy", 38); "N{1}quot; indicates with nth parameter

All-in-the-process conversions

int ioct = 0567;//octal number declaration, preceded by 0 (0) int iten = 1000;//decimal number declaration int ihex = 0xabcd;//hex number declaration, preceded by 0x (0 x), x and ABCD not case sensitive System.out.println ("octal 0567 is replaced with binary: integer.tostring (ioct, 2) =" +integer.tostring (IOCT, 2)); System.out.println ("octal 0567 is replaced with binary: integer.tobinarystring (IOCT) =" +integer.tobinarystring (ioct)); System.out.println ("octal 0567 is replaced by decimal: integer.tostring (ioct, ten) =" +integer.tostring (ioct, 10)); System.out.println ("octal 0567 is replaced by decimal: integer.tostring (IOCT) =" +integer.tostring (ioct)); System.out.println ("octal 0567 is replaced with 16 binary: integer.tostring (ioct, 2) =" +integer.tostring (ioct, 16)); System.out.println ("octal 0567 is replaced with 16 binary: integer.tohexstring (IOCT) =" +integer.tohexstring (ioct)); System.out.println (); System.out.println ("Decimal 1000 is replaced with 16 binary: integer.tostring (iten,16) =" +integer.tostring (iten,16)); System.out.println ("Decimal 1000 is replaced with 16 binary: integer.tohexstring (Iten) =" +integer.tohexstring (iten)); System.out.println ("Decimal 1000 is replaced with eight binary: integer.tostring (iten,8) =" +integer.tostring (iten,8)); System.out.println ("Decimal 1000 is replaced with eight binary: Integer.tooctalstrinG (Iten) = "+integer.tooctalstring (iten)); System.out.println ("Decimal 1000 is replaced with binary: integer.tostring (iten,2) =" +integer.tostring (iten,2)); System.out.println ("Decimal 1000 is replaced with binary: integer.tobinarystring (Iten) =" +integer.tobinarystring (iten)); System.out.println (); System.out.println ("hexadecimal 0xAbcd is converted to decimal: integer.tostring (ihex,10) =" +integer.tostring (ihex,10)); System.out.println ("hexadecimal 0xAbcd is converted to decimal: integer.tostring (Ihex) =" +integer.tostring (Ihex)); System.out.println ("Hex 0xAbcd replaced with eight binary: integer.tostring (ihex,8) =" +integer.tostring (ihex,8)); System.out.println ("Hex 0xAbcd replaced with eight binary: integer.tooctalstring (Ihex) =" +integer.tooctalstring (Ihex)); System.out.println ("Hex 0xAbcd replace binary: integer.tostring (ihex,2) =" +integer.tostring (ihex,2)); System.out.println ("Hex 0xAbcd replace binary: integer.tobinarystring (Ihex) =" +integer.tobinarystring (Ihex)); System.out.println ();//You can also replace any binary integer with any other arbitrary binary System.out.println ("hex 0xAbcd replaced with seven binary: integer.tostring (ihex,7) =" + Integer.tostring (ihex,7)); Program output: Octal 0567 is replaced with binary: integer.tostring (ioct, 2) = 1,011,101,118 binary 0567 is replaced with binary: integer.tobinarystring (IOCT) = 1,011,101,118 binary 0567 loaded into decimal: integer.tostring (ioct, 10) = 3,758 binary 0567 is converted to decimal: integer.tostring (ioct) = 3,758 binary 0567 is replaced with 16 binary: integer.tostring (ioct, 2) = 1778 binary 0567 is replaced with 16 binary: integer.tohexstring (ioct) =177 decimal 1000 is replaced with 16: integer.tostring (iten,16) = 3e8 Decimal 1000 Replace with 16 binary: integer.tohexstring (iten) =3e8 decimal 1000 Replace with eight: integer.tostring (iten,8) = 17,500 binary 1000 replace with eight: integer.tooctalstring (iten) =1750 decimal 1000 Replace with binary: integer.tostring (iten,2) = 11,111,010,000 binary 1000 Replace with binary: integer.tobinarystring (iten) = 11,111,010,006 binary 0XABCD converted to decimal: integer.tostring (ihex,10) = 439,816 binary 0XABCD converted to decimal: integer.tostring (ihex) = 439,816 binary 0xAbcd loaded into eight binary: integer.tostring (ihex,8) = 1,257,156 binary 0XABCD replaced with eight binary: integer.tooctalstring (ihex) = 1,257,156 binary 0xAbcd loaded into binary: integer.tostring (ihex,2) = 1,.01,010,111,100,11e,+16 binary 0XABCD Replace with binary: integer.tobinarystring (Ihex) = 1,.01,010,111,100,11e,+16 binary 0XABCD Replace with seven: Integer.tostring (ihex,7) =242140

  

What might be used in the Java race

Related Article

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.