Java Data types

Source: Internet
Author: User

1. Integer (the default type is int)

  If the data is larger than the range of type long, you can use the BigInteger class

Binary conversions:

Octal: 0 Opening
Hex: 0x or 0X start


Integer.tobinarystring (); //Convert to binary

Integer.tooctalstring (); //Convert to octal

Integer.tohexstring (); //Convert to hex

Type conversions:

If the size of the data does not exceed the type representation range you want to convert, you can automatically transform it.

Long type:

Long a = 123456L //l preferably capitalized, otherwise easily and 1 confused

2. Float type (default type is double)

  There are rounding errors in floating-point numbers, such as the use of the BigDecimal class if you want an exact number that does not produce rounding errors

  Avoid using floating-point types when comparing number sizes

The wording of E:

314e-2 = 3.14 //indicates 314*10^ ( -2)

Float usage:

float a = 3.14F //F indicates floating-point constant is float type

3. Characters

\ //escape character for special characters such as output ' \ \

Java Data types

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.