0 votes
1 view
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 (46.1k 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
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...