They appear to do exactly the same thing to me (also goes for
parseLong()etc, how are they different from
Also, which one of these is preferable and used more often by convention?
Best Answer:Well, the API for
Integer.valueOf(String)does indeed say that the
Stringis interpreted exactly as if it were given to
parseInt(String)returns a primitive
If you want to enjoy the potential caching benefits of
Integer.valueOf(int), you could also use this eyesore:
valueOf(String)may be more attractive than making a new object out of
parseInt(String)because the former is consistently present across
If you have better answer, please add a comment about this, thank you!