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
๐ŸŒ
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.
๐ŸŒ
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 โ€บ python โ€บ convert-integer-to-string-in-python
Convert Integer to String in Python - GeeksforGeeks
Explanation: format() places the integer inside the string placeholder {} and the returned value is a string.
Published: May 27, 2026
๐ŸŒ
Mimo
mimo.org โ€บ tutorials โ€บ python โ€บ how-to-convert-integer-to-string-in-python
How to Convert Integer to String in Python
Learn how to convert an int to a string in Python with str() and f-strings, avoid TypeError, and build clean filenames and messages.
๐ŸŒ
How to do in Java
howtodoinjava.com โ€บ home โ€บ string โ€บ convert int to string in java (integer.tostring vs valueof)
Convert int to String in Java (Integer.toString vs valueOf)
August 16, 2018 - String zero = Integer.toString(0); // "0" String negative = Integer.toString(-40); // "-40" String max = String.valueOf(Integer.MAX_VALUE); // "2147483647" String min = String.valueOf(Integer.MIN_VALUE); // "-2147483648" Neither method throws an exception for an int, because every int value has a decimal form. A wrong number in the output comes from the arithmetic before the call. For example, Integer.MAX_VALUE + 1 overflows to -2147483648 before it reaches toString(), and Math.addExact() reports the overflow instead.
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ how-to-convert-an-int-to-a-string-in-cpp
How to Convert an Int to a String in C++ โ€“ Integer Cast Tutorial
November 10, 2022 - Lastly, we extracted the string ... " years old"; // The user is 20 years old ยท You can use the to_string() method to convert int, float, and double data types to strings....
Find elsewhere
๐ŸŒ
FavTutor
favtutor.com โ€บ blogs โ€บ int-to-string-java
Convert Int to String in Java (5 Ways) | FavTutor
July 19, 2026 - Converting to a String gives access to individual digits through charAt(). public class Main { public static void main(String[] args) { int pinCode = 560034; String digits = String.valueOf(pinCode); System.out.println(digits.length()); // Output: 6 System.out.println(digits.charAt(0)); // Output: 5 } }
๐ŸŒ
FavTutor
favtutor.com โ€บ blogs โ€บ int-to-string-python
Convert Int to String in Python (6 Ways) | FavTutor
July 18, 2026 - In Python, the standard way to convert an integer to a string is the built-in str() function.
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);
๐ŸŒ
C++ Better Explained
cppbetterexplained.com โ€บ home โ€บ posts โ€บ c++ convert int to string (and string to int): complete guide | cppbe
C++ Convert int to string (and string to int): Complete Guide | CppBE
May 14, 2026 - C++ has clean, modern functions for both directions. This tutorial covers all of them. The simplest way to convert any numeric type to a string is std::to_string(), available since C++11:
๐ŸŒ
Sentry
sentry.io โ€บ sentry answers โ€บ java โ€บ how do i convert an integer to a string in java?
Convert Integer to String in Java with Three Methods | Sentry
October 2, 2026 - This solution covers three of the most common approaches: using the String.valueOf() method, using the Integer.toString() method, and concatenating an integer with an empty string.
๐ŸŒ
Replit
replit.com โ€บ home โ€บ discover โ€บ how to convert an int to a string in python
How to convert an int to a string in Python | Replit
April 14, 2026 - In this article, you'll explore key techniques, from the str() function to modern f-strings. We'll also provide practical tips, examine real-world applications, and offer advice to help you resolve common errors with your code.
๐ŸŒ
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.
๐ŸŒ
Oracle
docs.oracle.com โ€บ javase โ€บ tutorial โ€บ java โ€บ data โ€บ converting.html
Converting Between Numbers and Strings (The Javaโ„ข Tutorials > Learning the Java Language > Numbers and Strings)
Each of the Number subclasses includes a class method, toString(), that will convert its primitive type to a string. For example: int i; double d; String s3 = Integer.toString(i); String s4 = Double.toString(d);
๐ŸŒ
WsCube Tech
wscubetech.com โ€บ resources โ€บ c-programming โ€บ programs โ€บ int-to-string
How to Convert Int to String in C? 5 Ways With Code
September 17, 2026 - Learn five simple ways to convert an int to a string in C using sprintf(), itoa(), and other methods. Includes code examples!
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ integer-tostring-in-java
Integer toString() in Java - GeeksforGeeks
January 23, 2026 - This method returns a String object representing the value of the current Integer object.
๐ŸŒ
IONOS
ionos.com โ€บ digital guide โ€บ websites โ€บ web development โ€บ java int to string
How to convert an int to a string in Java - IONOS
December 18, 2024 - The method Integer(int).toString from the integer class ... If you want to know how to do the reverse and convert a string to an integer, check out the article in our Digital Guide.