Home:ALL Converter>Efficient Method of Converting int to String in Java

Efficient Method of Converting int to String in Java

Ask Time:2010-12-10T11:36:22         Author:Mudassir

Json Formatter

Integer.toString(int);

and

String.valueOf(int);

Which one among the above two methods is the efficient way of converting an int to String?

Thanks in advance.

Author:Mudassir,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/4405407/efficient-method-of-converting-int-to-string-in-java
Cameron Skinner :

String.valueOf calls Integer.toString, so I guess you could argue that Integer.toString is marginally more efficient.\n\nEDIT: With a modern compiler the calls will be inlined so there should be no difference at all between the two. With an ancient compiler the difference should still be negligible.",
2010-12-10T03:39:57
Zaid :

I think that the String.valueOf() method was just provided for the purpose of flexibility, Since the purpose is closely related with String class(in fact for the conversion to String). While the (Integer/Float/etc).toString() method is the authentic method for the purpose of String conversion. You can refer them as slightly overloaded method.",
2012-09-06T14:35:14
yy