1 How do I convert string strings to integer int?
A. There are two methods:
1). int i = Integer.parseint ([String]);
or i = Integer.parseint ([string],[int radix]);
2). int i = integer.valueof (my_str). Intvalue ();
Note: The string is converted to Double, Float, and Long in a similar way.
2 How do I convert an integer int to a string string?
A. There are three ways:
1.) String s = string.valueof (i);
2.) String s = integer.tostring (i);
3.) String s = "" + I;
Note: Double, Float, Long turn into a string in a similar way.
========================================================
How to convert int to string in Java
Method 1 int i=10; String s= "" +i;
This is a conversion made using the ToString mechanism of Java, where any type is converted to string when it is added to a string.
Method 2 int i=10; String s=string.valueof (i);
This is a conversion made using the factory method provided by the string class.
Which method is good? The first kind? More convenient. The second kind? more efficient.
multiple ways to convert int and string to each other in Java