I have integer status response from a REST API. I need to return string, so I use it like
return "" + statusCode
Is it fine way to do that or is it costly? Or should I use String.valueOf()
or is there another alternative?
No need - if you decompile the class file, you'll see that the compiler does this for you anyway. I think this makes the code very readable, however you might want to ask yourself why are you doing this anyway... if you are confident that returning a number as a string from a method is correct, this is a good way to do it, IMO.