Data types for Java

Source: Internet
Author: User
Basic data types

Java basic data types are divided into 8 categories:

8-bit =1b (bytes)

Digital type:

Byte:8 bits per byte-128-127 (based on the number of digits, you can calculate it yourself)

Short:16 bit two bytes

Int:32 bit 4 bytes

Long:64 bit 8 bytes

Floating point type:

Folat:32 bit single precision

DOUBLE:64 Double Precision

Character type:

Char:16 bit

Boolean type:

Boolean:8 or 1-bit controversial (own idea: one can say, only 0 and 1 can be expressed, so I think it is 1 bit. Some people think it's based on the system memory)

Conversions between data types

Large type conversions to small types require casting such as: int x= (int) Double;
Conversion of floating-point type to integral type requires forced type conversion

Data types for Java

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.