I have a method which takes String argument. In some cases I want to pass int value to that method. For invoking that method I want to convert int into String. For that I am doing the following:
aMethod(''+100);
One more option is:
aMethod(String.valueOf(100));
Both are correct. I don’t know which is appropriate? Which gives better performance?
Mostly this is happen in GWT. In GWT for setting size of panels and widgets I want to do this.
Since you’re mostly using it in GWT, I’d go with the ”+ method, since it’s the neatest looking, and it’s going to end up converted to javascript anyway, where there is no such thing as a StringBuilder.
Please don’t hurt me Skeet Fanboys 😉