There are multiple ways:

  • String.valueOf(number) (my preference)
  • "" + number (I don't know how the compiler handles it, perhaps it is as efficient as the above)
  • Integer.toString(number)
Answer from Bozho on Stack Overflow
๐ŸŒ
Browserling
browserling.com โ€บ tools โ€บ decimal-to-text
Decimal to Text Converter - Convert Decimal to String - Online - Browserling Web Developer Tools
Useful, free online tool that converts decimal integer values to plain text. No ads, nonsense, or garbage, just a dec to text converter. Press a button โ€“ get the result.
๐ŸŒ
Online String Tools
onlinestringtools.com โ€บ convert-decimal-to-string
Convert Decimal to a String โ€“ Online String Tools
Free online decimal to string converter. Just load your decimal and it will automatically get converted to a string. There are no intrusive ads, popups or nonsense, just a decimal to string converter. Load a decimal, get a string.
๐ŸŒ
Text Compare
textcompare.io โ€บ string-to-int-converter
String to INT Converter Online
String to Integer (INT) Converter is a tool that simplifies the conversion of textual data (strings) into integer values. In computer programming, strings are sequences of characters (text), and integers are numerical data types.
๐ŸŒ
Convert String
convertstring.com
Convert String - Online String Conversion tools
Convert String offers resources for converting strings between formats. If you need a fast free online tool for applying common string functions or string manipulation routines then you are in the right place!
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ different-ways-for-integer-to-string-conversions-in-java
Java Convert int to String | How to Convert an Integer into a String - GeeksforGeeks
April 9, 2025 - Using concatenation with an empty string. The Integer class has a static method toString() that returns a String object representing the specified int parameter. The argument is converted and returned as a string instance.
๐ŸŒ
PhraseFix
phrasefix.com โ€บ tools โ€บ decimal-to-string
Decimal to String Converter - PhraseFix
Free online tool that converts decimal to string. Simply enter the decimal and the online tool will convert it into text.
๐ŸŒ
Browserling
browserling.com โ€บ tools โ€บ text-to-decimal
Text to Decimal Converter - Convert Text to Decimal String - Online - Browserling Web Developer Tools
For example, if you're writing a web application that transfers messages using a simple non-binary text protocol, then it may get tricky to transfer multi-byte characters (such as Unicode symbols and emojis). With this utility, you can convert any text, Unicode glyphs, and multi-byte strings into decimal numbers (or integers).
Find elsewhere
๐ŸŒ
Kjur
kjur.github.io โ€บ jsrsasign โ€บ sample โ€บ tool_intary.html
jsrsasign: Integer array converter
This tool converts from a string of integer array (ex. ' [ 123, 34, 101, ... ] ') to a hexadecimal string or raw string.
๐ŸŒ
CodeGym
codegym.cc โ€บ java blog โ€บ strings in java โ€บ how to convert int to string in java
Convert int to String in Java
December 18, 2024 - The easiest way to convert int to String is very simple. Just add to int or Integer an empty string "" and youโ€™ll get your int as a String. It happens because adding int and String gives you a new String.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ c language โ€บ how-to-convert-an-integer-to-a-string-in-c
How to Convert an Integer to a String in C? - GeeksforGeeks
July 23, 2025 - We can convert an integer to a string manually by extracting each digit one by one and converting it to its corresponding character by using their ASCII code and storing it in the character array to form a string.
๐ŸŒ
Educative
educative.io โ€บ answers โ€บ how-to-convert-an-integer-to-a-string-in-java
How to convert an integer to a string in Java
It returns a string. You can use it as a static function of the Integer class like this: ... Or, use the normal version of the Integer classโ€™ object. This cannot be used with the primitive type int, so remember to convert it to an Integer first by passing it to the constructor or simple assignment using โ€˜=โ€™ operator (see the example below) :
๐ŸŒ
WsCube Tech
wscubetech.com โ€บ resources โ€บ c-programming โ€บ programs โ€บ int-to-string
How to Convert Int to String in C? 3 Ways With Code
October 23, 2025 - Learn three simple ways to convert an int to a string in C using sprintf(), itoa(), and other methods. Includes code examples!
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ convert-integer-to-string-in-python
Convert integer to string in Python - GeeksforGeeks
This is similar to f-strings but works with older versions of Python (before 3.6). ... The %s keyword allows us to insert an integer (or any other data type) into a string.
Published ย  July 12, 2025
Top answer
1 of 16
983

Normal ways would be Integer.toString(i) or String.valueOf(i).

The concatenation will work, but it is unconventional and could be a bad smell as it suggests the author doesn't know about the two methods above (what else might they not know?).

Java has special support for the + operator when used with strings (see the documentation) which translates the code you posted into:

StringBuilder sb = new StringBuilder();
sb.append("");
sb.append(i);
String strI = sb.toString();

at compile-time. It's slightly less efficient (sb.append() ends up calling Integer.getChars(), which is what Integer.toString() would've done anyway), but it works.

To answer Grodriguez's comment: ** No, the compiler doesn't optimise out the empty string in this case - look:

simon@lucifer:~$ cat TestClass.java
public class TestClass {
  public static void main(String[] args) {
    int i = 5;
    String strI = "" + i;
  }
}
simon@lucifer:~$ javac TestClass.java && javap -c TestClass
Compiled from "TestClass.java"
public class TestClass extends java.lang.Object{
public TestClass();
  Code:
   0:    aload_0
   1:    invokespecial    #1; //Method java/lang/Object."<init>":()V
   4:    return

public static void main(java.lang.String[]);
  Code:
   0:    iconst_5
   1:    istore_1

Initialise the StringBuilder:

   2:    new    #2; //class java/lang/StringBuilder
   5:    dup
   6:    invokespecial    #3; //Method java/lang/StringBuilder."<init>":()V

Append the empty string:

   9:    ldc    #4; //String
   11:    invokevirtual    #5; //Method java/lang/StringBuilder.append:
(Ljava/lang/String;)Ljava/lang/StringBuilder;

Append the integer:

   14:    iload_1
   15:    invokevirtual    #6; //Method java/lang/StringBuilder.append:
(I)Ljava/lang/StringBuilder;

Extract the final string:

   18:    invokevirtual    #7; //Method java/lang/StringBuilder.toString:
()Ljava/lang/String;
   21:    astore_2
   22:    return
}

There's a proposal and ongoing work to change this behaviour, targetted for JDK 9.

2 of 16
258

It's acceptable, but I've never written anything like that. I'd prefer this:

String strI = Integer.toString(i);
๐ŸŒ
Simonv
simonv.fr โ€บ TypesConvert
Types converter
Independently of the input format, conversion is limited to 64 bits. ... Conversion in SINT8 type of the input value results in overflow. The displayed value is the result of the overflow. Note that overflow of signed 8-bits integer is undefined and therefore the result given here is for ...
๐ŸŒ
DenCode
dencode.com โ€บ string
String Encoder / Decoder, Converter Online - DenCode
String encoding and decoding converter. e.g. HTML Escape / URL Encoding / Quoted-printable / and many other formats!
๐ŸŒ
DigitalOcean
digitalocean.com โ€บ community โ€บ tutorials โ€บ python-string-to-int-int-to-string
Python String to Int, Int to String | DigitalOcean
August 4, 2022 - But remember that the output integer is always in base 10. Another thing you need to remember is that the given base must be in between 2 to 36. See the following example to understand the conversion of string to int with the base argument.