1.int & String
int i=5678; String s= "";
int->string:s=i+ ""; or s=string.valueof (i);
String->int:i=integer.parseint (s); or i=integer.valueof (s). Intvalue ();
2.String & Float
String s= ""; Float f=12.21;
string->float:f= float.valueof (s); f = new Float (s); f = float.parsefloat (s);
Float->string:s= f.tostring ();
Summary: Conversions between strings and other types
(1) Conversion of other types to strings
① the string conversion method of the Calling class: X.tostring ();
② Automatic conversion: x+ "";
③ method of using String: string.volueof (X);
////////////////////////////////////////////////////////////////////////////
(2) string as a value, to other types of conversions
The ① is converted to the corresponding wrapper instance before the corresponding method is converted to another type.
For example, the character "32.1" converts the value of a double type to the format: New Float ("32.1"). Doublevalue (). can also be used: double.valueof ("32.1"). Doublevalue ()
② static Parsexxx method
String s = "1";
byte B = byte.parsebyte (s);
Short T = Short.parseshort (s);
int i = Integer.parseint (s);
Long L = Long.parselong (s);
Float f = float.parsefloat (s);
Double d = double.parsedouble (s);
③character getnumericvalue (char-ch) method
Java different type character conversion string/int/float/////