Skip to content

Latest commit

 

History

History
28 lines (19 loc) · 465 Bytes

File metadata and controls

28 lines (19 loc) · 465 Bytes

Integer to a String

If you have an integer you want to turn into a String you have two options.

One is to "add it" to an empty string.

~void main() {
int x = 4;
String xStr = "" + x;

IO.println(xStr);
~}

The other is to use the toString static method on Integer.

~void main() {
int x = 4;
String xStr = Integer.toString(x);

IO.println(xStr);
~}

I personally find the second one more direct, but opinions can reasonably vary.