Convert basic datatype to String
The String class already provides a static method to convert the base data type to String, which is the method that overloads the parameter String.valueOf()
There are the following types
(1) String.valueOf(Boolean b) : Convert a Boolean variable b to a String (2) String.valueOf(char c) : Convert c to String (3) String.valueOf(char[] data) : String. ValueOf (char[] data, int offset, int count) : Convert count of elements from char data to a string
(5) String.valueOf(float f) : String.valueOf(float f) : String.valueOf(float f) Convert float variable f to String (7) String.valueOf(int I) : Convert int variable I to String (8) String.valueOf(long l) : Convert long variable l toString(9) String.valueOf(Object obj) : Convert obj Object toString equal to obj.toString()
The basic data type that converts a String to a number
To convert a String to a primitive datatype, most require a wrapper class that uses the primitive datatype
For example, if String is converted to Byte, you can use Byte.ParseByte (String S). This type of method will throw a NumberFormatException if S is not parsed
(1) Byte: Byte. ParseByte (String S) : Convert s to Byte(2) Byte. ParseByte (String S, int Radix) : Convert s to byte based on radix. For example, byte.parsebyte (“11”, 16) will result in 17 (3) double: double. ParseDouble (String S) : Double (4) float: double. ParseFloat (String S) : double. ParseFloat (String S) : double. ParseFloat (String S) : double. ParseFloat (String S) : double. Convert s to int (6) long: long.parselong (String s)