This question already has an answer here:
(这个问题在这里已有答案:)
(Java int to String - Integer.toString(i)vs new Integer(i).toString() 11 answers)
(如何从int转换为String?)
(19个答案)
Given a number:
(给出一个数字:)
int number = 1234;
Which would be the "best" way to convert this to a string:
(这将是将其转换为字符串的“最佳”方式:)
String stringNumber = "1234";
I have tried searching (googling) for an answer but no many seemed "trustworthy".
(我曾尝试搜索(谷歌搜索)一个答案,但没有多少似乎“值得信赖”。)
There are multiple ways:
(有多种方式:)
String.valueOf(number)
(String.valueOf(number) (我的偏好))
"" + number
("" + number (我不知道编译器如何处理它,也许它与上面一样有效))
Integer.toString(number)
1.4m articles
1.4m replys
5 comments
57.0k users