The difference between their return types is the biggest reason:
static int parseint (String s)
The string argument is parsed as a signed decimal integer.
static Integer valueOf (int i)
Returns an Integer instance that represents the specified int value.
Static Integer valueOf (String s)
Returns an Integer object that holds the value of the specified String.
From the return value you can see their difference parseint () returns the base type int
The valueof () returns the wrapper class integer integer that can be used with the object method, and the int type cannot be converted to the object type.
The Integer.parseint (Chuan) return value is of type int.
The integer.valueof (Chuan) return value is integer. If you assign an integer to the int type, the JRE will do the work itself.
The difference is still there. If you write a method with a formal parameter of type int, for example:
void Test (int a) {
Todo:
};
When you call this method, test (Integer.parseint (Chuan)) will translate, but test (integer.valueof (Chuan)) will translate the error
The role of Java string.valueof ()
A cast of data is required to read the data, and a string.valueof (a) can be used to cast a to a string type
Sometimes a is already a string type, but for the rigor of the code, will also add string.valueof (a), then string.valueof (a) omitted will not be wrong.
But sometimes it involves a server problem, so it's better to join String.valueof (a).
Using string.valueof () for data conversion, this method returns a "null" string if the converted data is null
String) method, if the converted data is NULL, a null object is returned instead of a "null" string.
2017.4.14 the differences between Java parseint and valueof