Java Foundation--java Basic data types

Source: Internet
Author: User

The basic data types are detailed as follows:
Type Key words Length "bits" Range of values Description Wrapper type
Integral type Byte 8 (1 bytes) [ -128,27] Storing byte data (common) Byte
Short 16 (2 bytes) [ -2^15,2^15-1] Short
Int 32 (4 bytes) [ -2^31,2^31-1] Storing ordinary integers (common) Integer
Long 64 (8 bytes) [ -2^63,2^63-1] Store long integers (common) Long
Character type Char 16 (2 bytes) [0,65535]or[0,2^16-1] Store one character (common), Unicode encoding Character
Logic type Boolean 8 (1 bytes) True or False Storing logical variables (common) Boolean
Floating point Type Float 32 (4 bytes) Store floating-point numbers Float
Double 64 (8 bytes) Storing double-precision floating-point numbers Double
Note: 1. Conversion of basic data types: automatic type conversion (implicit type conversion): From small to large type conversions can be done automatically, with the following relationship: casts: From large types to small types require casts, which can result in loss of precision or overflow of 2. Data that can be directly allocated in the stack is the base data type; Reference data type , its object exists in the heap; the default integer type in 3.java is type int, and if you want to define float type, add L (L) after the value, and the default float is double-precision floating point, and to define float type, add F (f) After the value, 4.byte,char. The actual data stored in short three types are integers, using the following rules: Int direct amount can be directly assigned to Byte,char,short, as long as it does not exceed its representation range; Byte,char,short three types participate in the operation, they are converted to the int type in the calculation

Java Foundation--java Basic 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.