Java data Type (i)

Source: Internet
Author: User

Java data Type (i)

Java data types fall into two main categories: basic data types and reference data types.

First, the basic data type:

Data Type      Number of digits range of Values

BYTE 8-128~127

Short 16-32768~32767

Int 32-231 ~231-1

Long 64-263 ~263-1

Float 32/

Double 64/

Char + ' \u0000 ' ~ ' \uffff '

Boolean 1 True/false

1. Data type Conversion

Low height

byte short(auto-convert)

Short byte(cast)

* automatic conversion, also known as implicit type conversion

2. Conversion conditions:

(1) Mutual compatibility between two types of

(2) The target type is greater than the source type (that is, type promotion)

3. Cast (explicit type conversion): If the type of the value being converted is greater than its target type, some information will be lost.

II. Reference data types

1. definition: In Java , in addition to the above basic data variables, the rest are reference data types.

Objects are reference data types;

The reference type uses The new call construction method to assign the value.

2. Reference Data type assignment: Called with new construction method.

3. Use the same scenario as the basic data type:

(1) use as attribute type;

(2) used as the return value type of the method;

(3) Use as the form parameter type of the method

Three, the difference between the basic data type and the reference data type

function        Storage Mode method of assigning values

Basic Data: variables (simple values)        Storage in Stacks Direct Assignment

Reference type: Object reference stack Save reference, new,string

The heap is stored in the specific Classes and Wrappers

attribute value of the image can be assigned value

Iv. Assignment and operation

1. basic Data type assignment

Assigning values between basic data types is a copy of the value

2. the assignment of a reference type is called through the new constructor method

Assignment between reference types, which is the assignment between virtual addresses

3.== Operations

The address is determined when the reference data type is judged , that is, the virtual address returns true

Evaluates to a numeric value when judging the base data type, that is, the binary returns True

Java data Type (i)

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.