-Basic data type Object wrapper class.
| Byte |
Byte |
| Short |
Short |
| Int |
Integer |
| Long |
Long |
| Boolean |
Boolean |
| Double |
Double |
| Float |
Float |
| Char |
Character |
The most common role of the basic data type Object wrapper class,
is for the conversion between the base data type and the string type.
The base data type is converted to a string.
Method One: Basic data type + ""
Method Two: Basic data type. toString (basic data type value);
such as: Integer.tostring (34);//Turn 34 integers to "34";
The string is converted to the base data type.
Method One: Static method parsexxx
xxx a = xxx.parsexxx (String);
int a = Integer.parseint ("123");
Double b = double.parsedouble ("12.23");
Boolean B = Boolean.parseboolean ("true");
Method Two: Non-static method: Xxxvalue
Integer i = new Integer ("123");
int num = I.intvalue ();
Conversion between Systems
Decimal is converted into other systems.
Tobinarystring ();
Tohexstring ();
Tooctalstring ();
The other system is turned into decimal.
parseint (String,radix);
such as: Integer.parseint ("110", 2); 2-in-110 turn into decimal
Integer.parseint ("110", 10); 10 in 110 to decimal (unchanged)
JDK1.5 new feature in this regard
//integer x = new Integer (4);
Integer x = 4;//Auto Boxing. Equivalent to the last sentence
x = x + 2;//x+2:x for automatic unboxing. into the int type. and 2 for addition operations.
//And then boxing to X.
//I don't quite meet, the interview may be asked
Integer m = 128;
Integer n = 128;
SOP ("M==n:" + (M==n)); False
Integer a = 127;
Integer B = 127;
SOP ("A==b:" + (A==B));//The result is true. Because A and B point to the same integer object.
//Because when the value is in byte range, for the new attribute, if the value already exists, it will not open up new space.