String String with other format (int, boolean data type such as eight) interconversion


1, (String turn int) STR String = "123"; the Integer.parseInt int = A (STR);
(int turn String) A = int. 5; A = + STR String "";
2, (String turn boolean) String = STR "to true"; A = Boolean Boolean.parseInt (STR);
(Boolean turn string) boolean a = true; string str = a + "";
NOTE:. i can not be transferred directly into a character string type, it is necessary to use string method charAt class to get a character string
ii. If the value of a string type switch, if a numerical value not present in the character string, throws exception java.lang.NumberFormatException
iii. string Boolean turn when, if and only if the string is "true", the result is true, or any other Boolean strings result is transferred to false
. 3, the method valueOf string class: boolean boo = true; string str = String.valueOf (boo);

Guess you like

Origin www.cnblogs.com/mmzuo-798/p/11940032.html