Eight basic data types in Java

Source: Internet
Author: User

Eight basic data types in Java


The data type of the integer:


BYTE (byte) 8 bit (bit) 2 ^ 8 = 256-128 ~ 127
Short (16bit) 2 ^ 16 = 65536
int (shaping) 32bit 2 ^ 32
Long Plastic 64bit 2 ^ 64


Note: If an integer is not added to any of the identifiers, then the data of type int is the default.
If you need to represent this data as a long type of data, then you need to add the data followed by L to indicate that L is not case-sensitive, but it is recommended to use uppercase (easy to distinguish) Ljavac compilation does not pass.

Data type of decimal:


        float (single-precision floating-point)         32bit     Reserved 7-bit decimal place
        double (double-precision float)     64bit     Preserve 15-bit decimal digits


Note: If a decimal number is not added to any identity, then the decimal number defaults to the double type of data, and if you need to represent a float type, you need to add an F representation after the decimal. F is case-insensitive. Do not add F Javac compilation does not pass.

Boolean data type: Boolean data type only two values, true or False

Boolean 1 bytes or 4 bytes

If you use Boolean to declare a variable of a primitive type, then the variable takes up 4 bytes, and if you use Boolean to declare an array type, then the element of each array takes one byte.

Character type:

Char 2 bytes (16bit)

Eight basic data types in 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.