What is the better approach to convert primitive data type into String

后端 未结 9 603
独厮守ぢ
独厮守ぢ 2021-02-06 21:09

I can convert an integer into string using

String s = \"\" + 4; // correct, but poor style
or
String u = Integer.toString(4); // this is good

I

9条回答
  •  你的背包
    2021-02-06 21:48

    Appending a double quote is a bad way of doing it especially for readability. I would consider using some of the Apache util classes for conversion or writing your own utility methods for doing this type of stuff.

提交回复
热议问题