Java - Convert integer to string [duplicate]

2019-01-01 10:08发布

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".

7条回答
爱死公子算了
2楼-- · 2019-01-01 10:42

One that I use often:

 Integer.parseInt("1234");

Point is, there are plenty of ways to do this, all equally valid. As to which is most optimum/efficient, you'd have to ask someone else.

查看更多
登录 后发表回答