A summary of the Java language data types

Source: Internet
Author: User

8 Basic data Types

Data type bit byte value range

BYTE 8 1-128~127

Short 16 2-32768~32767

int 32 4-231~231-1

Long 64 8-263~263-1

Float 32 4 slightly

(Float a=3.0; C language does not error,java default to double type, need to be changed to float a=3.0f; )

Double 64 8 slightly

Char 2 '\u0000'~'\uffff '

Boolean 1 slightly true/false

Assignment: Assigns a value directly and copies the value .

Storage location: value stored in stack

= = Operation : Binary returns true

Reference type

Defined:

Reference type except for the base data type

Including:

classes in 1.API, such as String,File

2. custom classes, such as Personalaccount,creditaccount

3. Arrays , such as int[],string[]

Application:

1. use as a type of attribute

2. Use the return value type as a method

3. use as a form parameter type for a method

Assignment Value :

use new, String to assign a value, Copy the address .

Storage location:

A reference is stored in the stack, and the property value of the specific object is stored in the heap.

= = Operation :

True if the virtual address is the same

Data type conversions

Low -> High (target type > Source Type)

Byte -> short does not error, automatic conversion;

High -> Low

Short ->byte error, forced conversion required :(byte) short -> Byte

A summary of the Java language 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.