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