Android common data type (String, int, float, double, long) conversion
Because often used to change the type of equipment, so tidy, easy to find:
A, String turn int, float, double, long.
int i = Integer.parseInt(str) 或者 int i = Integer.valueOf(str).intValue();
float f = Float.parseFloat(str) 或者 float f = Float.valueOf(str).floatValue();
double d = Double.parseDouble(str) 或者 double d = Double.valueOf(str).doubleValue();
long l = Long.parseLong(str) 或者 long l = Long.valueOf(str).longValue();
byte b = Byte.parseByte (str);
short t = Short.parseShort(str);
Two, int turn String.
String s = String.valueOf (value); // wherein the value is any one of a digital type
String String.valueOf = S (I);
String Integer.toString = S (I);
String S = "" + value; // wherein the value is any type of a digital
Note: Double, Float, Long transfer method similar to a string of
Three, float switch int, String.
float f= 0.0f;
int b = (int) f; // with (int) cast integral B
int = B Math.round (F); // use round mode converter integer
String s= String.valueOf(f);
String s= f + “”;
String s= f.toString();