Migration time--May 26, 2017 17:47:37
Author:marydon
Third, Java basic data type, encapsulation class between the mutual transformation
(ii) Operation string
3.2.1 String splitting of strings
Implementation: Split () method
Usage: string.split ("specified character"), specifying the character if it is a special string that needs to be escaped with "\ \"
Example:
String cookiestr = "userid$1|username$%e8%b6%85%e7%ba%a7%e7%ae%a1%e7%90%86%e5%91%98|home$index|" ; if (Cookiestr.indexof ("UserId") >-1) { = cookiestr.split ("\\|") ); for (String cook:cooks) { = cook.split ("\\$"); or [$] if (str[0].equals ("UserId")) { return str[1 ]; } }}
updatetime--2017 January 9 17:31:14
(c) Format conversion
3.3.1 the mutual transformation of String and int
3.3.1.1 String-->int
/***/int r1 = integer.parseint ("123");
3.3.1.2 int-->string
/***/ // using the String Class ValueOf () method String str1 = string.valueof (3); // Use the ToString () method of the integer class String str2 = integer.tostring (3); // Stitching Empty characters String STR3 = 3 + "";
3.3.2 The conversion of String to Integer
3.3.2.1 String-->integer
/***/= integer.valueof ("123");
3.3.2.2 integer-->string
/***/=1 = r.tostring ();
3.3.38 basic data types and corresponding package classes can be directly converted between
Example:
long l = 1= l; // Long Turn long long l2 = L; // Long Turn long
3.3.4 int and integer conversion
3.3.4.1 Int-->integer
/***/// call the integer valueOf () method integer r3 = integer.valueof (123); // Automatic Conversion Integer r4 = 123; // instantiating an Integer object New Integer (123);
3.3.4.2 Integer-->int
/***/// auto convert int r5 = R2; // Call the Intvalue () method of the integer class int r6 = R3.intvalue ();
3.3.58 basic data types converted to string types
// method One (with this) = string.valueof (123); // Method Two Call the ToString () method corresponding to the encapsulated class long L2 = 1= long.tostring (L2);
3.3. Encapsulation class of 68 basic data types converted to String type
// Use the ToString () method to convert to a string type; Long L2 = 1= l2.tostring ();
3.3.7 string types into eight basic data types
// Call the pase+ "base data type" for the corresponding wrapper class long l3 = Long.parselong ("123");
3.3.8 wrapper class for converting string types to eight basic data types
// Call the ValueOf () method of the corresponding wrapper class Long L3 = long.valueof ("123");
3.3.9 Package classes cannot be converted directly to each other
java-conversion between basic data types