Java notes--data types

Source: Internet
Author: User

We refer to int, float, double, boolean, and so on as the basic type (primitive type), which is the special class. We can interpret an integer as an object of type int. The int type can have an assignment, addition, subtraction and other operation interfaces. The normal type can be seen as an extension of the basic type. We've seen the basic type as a data member, a parameter to a method, a method's return value, and an automatic variable inside a method. Naturally, ordinary types of objects, such as battery and torch, can also be used in these places.

In the C language, the available data types (basically) are already preset, such as int, float. In Java, in addition to using these preset data types, we can customize the type of data we want by using a class, and then use it through a combination. But the basic type and the normal type are still different. Basic types are often used and occupy little memory space, so in Java, for efficiency, these basic types differ from the memory management of ordinary types (that is, custom classes). For example, once the base type is declared, the memory space is allocated, and the normal type needs to allocate memory space using the New keyword.

Java provides the appropriate generic type for each base type. For example, an int primitive type corresponds to an integer type. If you turn an object of the base type into a corresponding normal type variable, the so-called basic type becomes a generic type (no more memory-management differences).

In this way, we have a deeper understanding of the concept of "all objects" in Java.

  • This article is from: Linux Tutorial Network

Java notes--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.