1 1 Vote

Java: IntToStr - Convert Integer Number to String

Question by Guest | 07/09/2017 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?



Show Profile | Message
1Best Answer
1 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 08/02/2020 | Created on 07/09/2017

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 articles on askingbox.com. How to do.