A basic type wrapper class
The underlying data type is stored in the stack area of the memory, and you can convert the underlying data type to a reference data type by wrapping the class, that is, in the heap and stack.
There are 8 kinds of basic data types, and there are 8 kinds of packaging classes. Byte,short,integer,long,float,double,character,boolean, respectively. Class
The wrapper class is in Java. In the Lang packet.
1 Public classTest1 {2 3 Public Static voidMain (string[] args) {4 //TODO auto-generated Method Stub5Integer i=NewInteger (5);6Integer i2=NewInteger ("23");7Integer i3=integer.valueof (3);8Integer i4=integer.valueof ("567");9 Ten intA=I.intvalue (); One floatf=I.floatvalue (); AString s=i.tostring (); -String s2=integer.tostring (5); - intS3=integer.parseint ("123"); the } -}
Two: Automatic package unpacking
Automatic package unpacking is a mechanism introduced by JDK5.0.
Packaging: Objects based on the underlying data type
Unpack: Object--The underlying data type.
Automatic package unpacking refers to the automatic package and unpacking operation at the right time.
Commonly used in collection classes.
ImportJava.util.*; Public classTest2 { Public Static voidMain (string[] args) {//TODO auto-generated Method StubList l=NewArrayList (); L.add (1); L.add (2.5); L.add (true); intI= (int) L.get (1); BooleanB= (Boolean) L.get (2); }}
Java basic type wrapper class with automatic package unpacking