String int
int i=12345;
String s= "";
The first method: s=i+ "";
The second method: S=string.valueof (i);
What is the difference between these two methods? Does it work the same? Are they interchangeable under any circumstances?
String-INT
S= "12345";
int i;
The first method: I=integer.parseint (s);
The second method: I=integer.valueof (s). Intvalue ();
What is the difference between these two methods? Does it work the same? Are they interchangeable under any circumstances?
Here's the answer:
The first method: s=i+ ""; produces two string objects The second method: S=string.valueof (i); Use static methods of the string class directly, producing only one object The first method: I=integer.parseint (s);//Use static methods directly, do not produce extra objects, but throw exceptions The second method: I=integer.valueof (s). Intvalue ();//integer.valueof (s) equals the new Integer (Integer.parseint (s)) and throws an exception, but produces an extra object |
--------------------------------------------------------------------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 turns into Double, Float, and Long in the same way. 2 How do I convert integer int into 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.
type conversion of int, string in Java