11 Vote

Java: IntToStr - Convert Integer Number to String

Question by Guest | 2017-09-07 at 19:07

I would like to carry out a conversion of an integer number to a string in Java in order to be able to output the number.

I know the function IntToStr from other programming languages for this purpose, but Java seems not to know this function. What can I do?

1Best Answer1 Vote

Like so often in life, there are several ways to reach your aim.

Here are three examples:

int i = 123;

String s1 = String.valueOf(i);
String s2 = "" + i;
String s3 = Integer.toString(i);

This code writes the string representation of the number 123 into the string variables s1, s2 and s3.
Last update on 2020-02-08 | Created on 2017-09-07

ReplyPositive Negative

Related Topics

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.


Ask your own question or write your own article on askingbox.com. That’s how it’s done.