Java Learning Codex (3) Java basic data types and reference data types

Source: Internet
Author: User
Tags java reference

There are eight basic data types for Java, each of which corresponds to a reference data type.

Java basic data type: 1) Numeric byte 1 byte range -128--127 (calculation Method -2^ (bytes *8-1)--2^ (bytes *8-1)-1)

Short 2 byte range -2^15--2^15-1

int 4 byte range -2^31--2^31-1

A long 8 byte range -2^63--2^63-1 is usually added with an F when defined

2) Boolean type Boolean 1 bytes True or false is commonly used to determine

3) Float type float 4 bytes is usually defined as adding an F as, float F = 3.15f;

Double 8 bytes Typically use a double to define a floating-point number with high precision

4) Character type char 2 bytes

Java reference data type: Java is an object-oriented programming language, for the objects we define are reference data types, which can be referenced in detail.

  

Each base type corresponds to a reference data type, Byte>>byte,.... double>>double. Notice where the int>>integer,char>>charater.

Differences between the basic data type and the application data type

The base data type points to a specific value that allocates memory space when the variable is declared, while the reference data type does not allocate space when declared, and the memory space is allocated only when you create the object, and the variable name points to that memory space.

So for

This requires us to pay special attention to creating a basic data type that points to the same value, so it is the same, and the reference data type creates a new object and points the variable to that object, so the value is the same as the object that does not represent the two variables.

Java Learning Codex (3) Java basic data types and reference data types

Related Article

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.