Conversion between String and Basic Data

xiaoxiao2021-03-06  66

1. STATIC method that converts basic data type to string is provided in the StringString category, which is also available in String.Valueof (). There are several String.Valueof (Boolean B). : Convert Boolean Variable B Converting into Strings String.Valueof (Char C): Converts CHAR Variable C to String String.Valueof (Char [] DATA): Convert CHAR Array Data into Strings String.Valueof (char [] Data, int offset, int count: Take the CHAR array DATA by DATA [Offset] to convert the count element to strings String.Valueof (Double D): convert Double V.valueof (Float F) String.Valueof : Convert FLOAT VRD F to String String.Valueof (INT I): Convert INT Variable I to String String.Valueof (Long L): Convert the long variable L to string string.Valueof (Object Obj): Convert the OBJ object into a string, equal to OBJ.TOSTRING () usage such as: int i = 10; string str = string.valueof (i); this time STR will be "10" 2. String is converted into a number of numbers Data types To convert String into basic data type, there is a need to use basic data type packages, such as String Convert to BYTE, can use Byte.ParseByte (String s) This category If you cannot lose S analysis NumberformatexceptionByte: byte.ParseByte (String s): Convert S to Bytebyte.ParseByte (String S, INT RADIX): Convert S with RADIX to BYTE, such as Byte.ParsebyTe ("11", 16) Get 17Double : Double.Parsedouble (String S): Convert S to Doublefloat: Double .parsefloat (String S): Convert S to floatint: integer.Parseint (String S): Convert S to INTLONG: long.parselong (String S): Convert S to long usage, like: try {string str = "1234 "; int a = integer.Parseint (STR);} catch (number {system.out.println (" Parse Int Error !! " E);}

转载请注明原文地址:https://www.9cbs.com/read-84258.html

New Post(0)