Basic data types in Java and encapsulation classes

Source: Internet
Author: User

A variable is a request for memory to store a value. In other words, when creating a variable, you need to request space in memory.
The memory management system allocates storage space for variables based on the type of the variable, and the allocated space can only be used to store that type of data.
Therefore, you can store integers, decimals, or characters in memory by defining variables of different types.

Two big data types for Java:

(i). Built-in data type (base data type)

16 Types of numbers (byte, short, int, long, float, double) + void

8 16 32 64 32 64 bit


21 Character Types Char

16-bit Unicode characters


31 BOOL Boolean types

1 guests

(ii). Reference data type

Reference type variables are created by the constructors of the classes and can be used to access the referenced objects. These variables are specified as a specific type at the time of declaration. Once a variable is declared, the type cannot be changed.

objects, arrays are reference data types, and the default values for all reference types are null.

The base data type can only be passed by value, while the encapsulated class is passed by reference.

void no return value type, as an object of the pseudo-type corresponding class, is also considered to be the basic data type

Basic data types in Java and encapsulation classes

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.