Java wrapper class

Source: Internet
Author: User

1. Java wrapper class

Wrapper class Correspondence Table

Basic data types

Packing class

Byte

Byte

Boolean

Boolean

Short

Short

Char

Character

Int

Integer

Long

Long

Float

Float

Double

Double

2. Packing class Assignment (values ())

Intenger integer1 = new Integer (100);//Create a new integer object

Intenger Integer2 = 100;//is equivalent to the following values (100)

Integer Integer3 = integer.values (100); Takes 100 of the integer object in the cache, and no object is created

The Integercache class is used in integer to cache an integer object of 128-127. So the number in the-128-127 directly takes the cached integer object.

= = Basic type comparison value, object compare address, new creates an object.

3. Cache objects

Wrapper class Correspondence Table

Basic data types

Packing class

Byte

Byte (-128-127)

Boolean

Boolean (Compare String)

Short

Short (-128-127)

Char

Character (0-128)

Int

Integer (-128-127) may be extended according to configuration

Long

Long (-128-127)

Float

Float (None)

Double

Double (None)

4. Hashcode (rewrite)

Wrapper class Hashcode Returns the base type value

5. Equal (rewrite)

The basic type value of the wrapper class equal comparison

Java wrapper class

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.