The integer of the Java species is the wrapper type of int
1. Integer is the wrapper type of int, the data type is class and the initial value is null
2. When initializing
int i = 1new Integer (1);
3. Automatic packing and unpacking of class
1) Automatic packing
New Integer (1); // using a normal declarative method Integer i = 1; // using auto-boxing
2) Automatic Unpacking
Integer num = ten; // Automatic Boxing System.out.print (num--); // Automatic Unpacking
3) auto-unpacking and In-box to enjoy the Meta-mode
-128~128 (8bit Numeric) value, The memory will be reused after being boxed (that is, variables with different names 8bit numbers are the same in Memory)
A number other than -128~127, each declaration creates a new object, so the boxed object is not equal even if the unboxing value is the same (= = result is False)
4. The packaging classes in Java
1) Packing class is final type
2) Packaging class Support variable conversion
Byte |
Java.lang.Byte |
Boolean |
Java.lang.Boolean |
Short |
Java.lang.Short |
Char |
Java.lang.Charactor |
Int |
Java.lang.Integer |
Long |
Java.lang.Long |
Float |
Java.lang.Float |
Double |
Java.lang.Double |
5. Methods of the Integer class
1) Construction Method
Integer (int value) // use number integer (string s) // number represented by string
2) method
return value |
Name |
Function |
Type conversions |
|
|
Byte |
Bytevalue () |
Returns a byte type |
Double |
Doublevalue () |
Returns a double type |
Float |
Floatvalue () |
... |
Int |
Intvalue () |
|
Long |
Longvalue () |
|
Short |
Shortvalue () |
|
String |
|
|
String |
ToString () |
A String object that represents the value |
Static String |
ToString (int I) |
A String object that represents the specified integer |
Static String |
toString (int i, int radix) |
An integer string object that represents the specified cardinality |
Static String |
Tobinarystring (int I) |
Binary unsigned string |
Static String |
Tohexstring (int I) |
Hexadecimal unsigned string |
Static String |
Tooctalstring (int I) |
Octal unsigned string |
static int |
parseint (String S) |
Convert a string to an integer |
static int |
Reverse (int I) |
Reverse the order of the bits of the twos complement |
static int |
Rotateleft () |
Loop left Shift |
static int |
Rotateright () |
|
Int |
Hashcode () |
Return hash code |
Int |
CompareTo (Integer) |
Compare the values of two Integerd |
|
|
|
Wrapper class represented by Java integer