Java--long and Long/integer and long

Source: Internet
Author: User

Everything in Java is an object, because there are basic data types.

Basic data types have a corresponding base data Type Packager, and their base data Type Packager is an object.

J2SE 5.0 introduces boxing and unboxing, which are the relationship between the basic data type and the basic data Type Packager

Long and long

Long's inheritance relationship:

A few messages:

1, long by final modification, not variable

2. Parent class is abstract class number

3, realize the comparable interface, can be compared

public static long valueOf (long L)

Document translation:

Returns a long instance that represents the specified long value. If you do not need a new long instance, you should usually prefer this method instead of a long (long) constructor.

Because this method can generate significantly better spatial and temporal performance by caching frequently requested values. Note that unlike the corresponding methods in the integer class, this method does not need to cache values in a specific range.

Source:

public static Integer valueOf (int i)

Document Translation :

Returns an integer instance that represents the specified int value. If you do not need a new integer instance, you should usually prefer this method instead of the constructor integer (int).

This method can produce significantly better spatial and temporal performance by caching frequently requested values. This method will always cache values from 128 to 127 (inclusive) , and can cache other values outside of this range .

Ingeger and int:

An integer inheritance relationship:

Similar to Long

integer.valueof (int i) can be cached outside the range, you can change the upper limit by the command line, but the lower limit cannot be changed, the source code is reflected:

Note

Debug is one of the best tools to understand the source code.

Java--long and Long/integer and long

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.