Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (3.9k points)

Given a number:

int number = 1234;

Which would be the "best" way to convert this to a string:

String stringNumber = "1234";

1 Answer

0 votes
by (46k points)

There are various ways:

  • String.valueOf(number) (my choice)
  • "" + number (I don't understand how the compiler manages it, possibly it is as useful as the above)
  • Integer.toString(number)

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Aug 6, 2019 in Java by Anvi (10.2k points)

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...