The basic data types in Dark Horse programmer-java

Source: Internet
Author: User

------<a href= "http://www.itheima.com" target= "blank" >java training, Android training, iOS training,. NET training </a>, look forward to communicating with you! -------

the data types in Java are divided into two large categories: the base data type and the reference data type.

The basic data types can be divided into four categories: integer data type, decimal data type, character type, Boolean type.

The integer data type is also divided into:byte,short,int(integer),long (length integer). The default is type int. If you do not assign a value, the default value is 0. (long is assigned by adding an L to the integer value ).

Decimal data types are divided into: float (floating-point) ,double (double-precision floating-point type). The default is type. If you do not assign a value, the default value is 0.0 f).

Character type ,javaunicode code. java '

the Boolean value in Java is boolean not bool, only two values are true and false, thedefault value is false andcannot participate in data type conversions.

Data type conversion rules:

1. Eight data types can be converted to each other in addition to the Boolean type

2. Automatic data type conversion: low-precision to high-precision automatic conversion, and in the operation is first converted to high-precision re-operation.

Long L_1 = 123;// Automatic data type conversion

3. forced type conversion: high-precision to low-precision non-forced type conversion will be error, but high precision to low precision conversion will lose precision, it is recommended not to do so.

float f_1 = (float) d_1;

4. Data accuracy from low to High:byte<short<int<long<float<double

5. If the integer does not exceed the range of byte, short ,char, You can assign this integer directly to byte, short,char

6. A variety of data types to do mixed operations, first converted into the largest capacity of the kind of the operation

The basic data types in Dark Horse programmer-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.