Java data type, java Basic Data Type

Source: Internet
Author: User

Java data type, java Basic Data Type

1. Basic types: 8

Number: INTEGER: byte 1 byte (-128 to 127) one byte occupies 8 bits 1bit =

Short: 2-byte short integer

Int: integer 4 bytes

Long: 8-byte long integer

Float: 4-byte float: * 7 digits

Double: double Floating Point type, 8 bytes // ******* valid number sixteen

Non-numeric type: boolean indicates the logical type. Values true and false are false.

Character Type: char: represents A single character, 1 byte, and the value is included in ''. For example, 'male' '1', 'A', A single Chinese character, letter, and number are supported.

2. reference types: Three

Class type (Packaging class (String is a special packaging type), custom type, JDK built-in class)

Interface Type

Array type

Enumeration type

3. type conversion:

Automatic conversion: the type with low precision can be automatically converted to a type with high precision.

Forced conversion: converts a type with high precision to a type with low precision to a forced conversion with a loss of precision.

4. in java, common data types range from small to large (precision from high to low): byte <short <char <int <float <double.

5. Forced conversion of data types:

1). the string type and int or long type are converted according to the ASCII code table.

Syntax format (char) 97; (int) 'A'; (long) 'B ';

(The lowercase letter range is 97-122, and the upper-case letter range is 65-90)

2). Small-to-large conversion between numeric models, automatic conversion, large-to-small conversion, forced conversion

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.