-----------Android Training, Java training, Java Learning Technology blog, look forward to communicating with you. ------------
I. Basic data type Object wrapper class
A the benefit of encapsulating basic data types into objects is that you can define more functional methods in the object to manipulate the data.
b One of the most common operations: for the conversion between the base data type and the string.
c) For example: Integer Parselnt method, Intvalue method.
D The class used to describe the object is called the basic data type Object wrapper class.
Two. String à basic type
A The use of static methods in the package half class Xxxparsexxx
I. int parseint ("intstring");
Ii. long Parselong ("|longstring");
Iii. boolean Parseboolean ("booleanstring");
IV. Only character have no parse method.
b If the string is encapsulated by an integer.
I. Another non-static method can be used, intvalue ();
Ii. convert an Integer object to the base data type value.
c) integers have different embodiment of the system
I. Decimal à other integer.tobinarystring (60); Integer.tooctalstring (60); Integer.tostring (60,16);
II. Other system à decimal integer.parsenint ("110", 10);
d The integer class Overrides Equals () in object, so the integer object calls the Equals () method when it is a value.
e) simplifies the definition after JDK1.5
I. Integer x = new Integer (4); can be written directly
Ii. Integer x = 4;//Automatic Boxing
Iii. x = x + 5;//automatic unpacking, through the Intvalue method.
f) need to be aware
I. In use, the Integer x =null; The code above will appear nullpointerexception.
II. Automatic boxing, if the boxed is a byte, then the data will be shared without reopening space.
1. Integer = 127;integer = 127; System.out.print (x==y);//true
2. Integer = 128;integer = 128; System.out.print (x==y);//false
Iii. a small to large sort of number for a string.
1. How to get to these values in this string that need to be sorted.
2. A string object may be used to cut a large string into several small strings.
3. The value eventually becomes a small string, and the string becomes the base data type that can use the wrapper class.
Iv. Specific steps:
1. Turn the string into an array of strings String[]str_arr = Numstr.split ("");
2. Convert a string array to an int array int num_arr = Tointarray (Num_arr); create Tointarray (string[) arr); method
3. Sort an array of int
4. Converts a sorted array of int into a string
Three. String class
A The string is a special object
b The string cannot be changed once it is initialized
c) String str = "ABV";
d) String str = new String ("abc"); The string type cannot be changed once it is initialized.
e) The string class is a replication of the Equals method in the object class. This method is used to determine whether the string is the same.