converting string strings to integer int
A. There are 2 methods:
1). int i = Integer.parseint ([String]); or i = Integer.parseint ([string],[int Radix]);
2). int i = integer.valueof (my_str). Intvalue ();
PS:
the string turns into Double, Float, and Long in a similar way.
The first method: I=integer.parseint ([String]),//using static methods directly, does not produce extra objects, but throws an exception.
The second method: I=integer.valueof (MY_STR). Intvalue ();//integer.valueof (my_str) equals the new Integer (Integer.parseint (MY_STR) ), an exception will also be thrown.
Second, convert integer int to string string
A. There are 3 ways:
1.) String s = string.valueof (i);
2.) String s = integer.tostring (i);
3.) String s = "" + I;
PS:
Double, Float, and Long turn into strings in a similar way.
1th Method: S=string.valueof (i);//Use the static method of the String class directly, producing only one object.
The 3rd method: s= "" + i; A two string object is generated.
Conversion of string and int in Java