Advanced Java basic syntax

Source: Internet
Author: User

Package (WRAP) Basic data type

Basic data types: Long, Int, double, float, Boolean, byte, etc. In Java, these are not objects, but pure data.

If you package the basic data type into an object, you can operate on this object as if you were using the basic data type as an object.

You can use the int, long, double, float, Boolean, byte, and other corresponding integer, long, double, float, Boolean, and byte classes for packaging and object operations.

 

 

Automatic packing and unpacking

The automatic packing function is provided after j2se 5.0. You can directly package the basic data type as follows:

Integer integer = 10;

Or:

Int I = 10;

Integer integer = I;

You can also use a more general java. Lang. Number class for automatic packing:

Number = 3.14f;

3.14f is automatically packed as float and then specified to number.

It can be automatically packed or split from j2se 5.0:

Integer Foo = 10;

int foof = Foo;

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.