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 - Tip: We generally convert primitive ... in java we deal with strings. Converting Integers to Strings involves using the Integer classes toString() or String.valueOf() for direct conversion....
Discussions

java - How do I convert from int to String? - Stack Overflow
I'm working on a project where all conversions from int to String are done like this: int i = 5; String strI = "" + i; I'm not familiar with Java. Is this usual practice or is something wrong, a... More on stackoverflow.com
🌐 stackoverflow.com
Converting a Number to a String
The docs will answer that question quite clearly https://docs.oracle.com/javase/7/docs/api/java/lang/Integer.html#toString(int) https://docs.oracle.com/javase/7/docs/api/java/lang/String.html#valueOf(int) under the String.valueOf(int) description: The representation is exactly the one returned by the Integer.toString method of one argument. to make it even more clear if we look at the source code for String.valueOf(int) https://hg.openjdk.java.net/jdk7u/jdk7u6/jdk/file/8c2c5d63a17e/src/share/classes/java/lang/String.java we find that it literally just calls Integer.toString(int) public static String valueOf(int i) { return Integer.toString(i); } More on reddit.com
🌐 r/javahelp
3
6
August 14, 2022
How does computer converts integer to string?
It somewhat depends on the character set used. For ASCII, it's literally just a big lookup table that maps number to character. For unicode it's a bit more complex but on a basic level it's still similar. More on reddit.com
🌐 r/learnprogramming
16
82
March 29, 2022
Which is the best way to convert int to string in golang ?
  1. is plain wrong

  2. is the most lightweight (in terms of dependency and performance)

  3. is the most flexible

More on reddit.com
🌐 r/golang
7
6
July 3, 2020
🌐
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 - convert int to String, Java: 5 our int: 5 adding int = 5 and String = "5". The result is a new String = 55 convert Integer to String: 7 our Integer: 7 adding Integer = 7 and String = "7".
🌐
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 - 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. Web hosting Get your site online fast without breaking the bank ... One of the simplest and most practical methods for con­vert­ing a Java int to a string is the method Integer(int).toString.
🌐
Educative
educative.io › answers › how-to-convert-an-integer-to-a-string-in-java
How to convert an integer to a string in Java
System.out.println("After conversion (using Static method): " + Integer.toString(x).getClass().getName()); ... These two classes build a string by the append() method.
🌐
GeeksforGeeks
geeksforgeeks.org › java › integer-tostring-in-java
Integer toString() in Java - GeeksforGeeks
January 23, 2026 - Example: This example shows how to convert an Integer object into a String using the toString() method in Java.
🌐
freeCodeCamp
freecodecamp.org › news › how-to-convert-integer-to-string-in-java
Int to String in Java – How to Convert an Integer into a String
January 5, 2023 - To be able to use the DecimalFormat class in the example above, we imported it: import java.text.DecimalFormat;. We created the integer age variable. We then created a new object of the DecimalFormat class called DFormat. Using the object's format() method, we converted age to a string: DFormat.format(age);.
Find elsewhere
🌐
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
1 month ago - You can also convert an Integer to a String by concatenating it with an empty string (""): class Main { public static void main(String[] args) { int number = 123; String numberString = number + ""; System.out.println("Converted String: " + ...
🌐
iO Flood
ioflood.com › blog › int-to-string-java
Int to String Java Conversion: Methods and Examples
February 26, 2024 - Many developers find themselves puzzled when it comes to handling this task, but there’s a solution. Think of Java as a skilled interpreter, capable of translating integers into strings.
🌐
Scaler
scaler.com › home › topics › java convert int to string
Convert int to String in Java - Scaler Topics
February 9, 2024 - The append method converts the integer to a StringBuffer instance, and the toString method converts it into a String. ... Explanation: Similar to StringBuffer, the StringBuilder class is used for creating a mutable sequence of characters. The difference lies in synchronization; StringBuilder ...
🌐
FavTutor
favtutor.com › blogs › int-to-string-java
Convert Int to String in Java (5 Ways) | FavTutor
July 19, 2026 - In Java, you convert an int to a String with Integer.toString(number) or String.valueOf(number).
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);
🌐
Edureka
edureka.co › blog › convert-int-to-string-in-java
How to Convert Int to String in Java? String Conversion Example | Edureka
November 29, 2022 - Java allows you to convert values from one data type to another, under certain conditions. You can convert a string variable to a numeric value and a numeric value into a string variable.
🌐
BeginnersBook
beginnersbook.com › 2015 › 05 › java-int-to-string
Java int to String Conversion With Examples
Method signature: public static String toString(int i) Parameters: i – integer that requires conversion · Returns: String representing the integer i. ... public class JavaExample { public static void main(String args[]) { int ivar = 111; String str = Integer.toString(ivar); System.out.println("String is: "+str); //output is: 555111 because the str is a string //and the + would concatenate the 555 and str System.out.println(555+str); //output is: 666 because ivar is int value and the //+ would perform the addition of 555 and ivar System.out.println(555+ivar); } }
🌐
YouTube
youtube.com › watch
3 Ways to Convert Int to String in Java | Convert Integer to String in Java - YouTube
#strings #java #integers Convert Integer to String in Java: In this video, you will learn how to convert Int to String in Javausing different ways.video time...
Published: January 9, 2021
🌐
Software Testing Help
softwaretestinghelp.com › home › java › 8 methods to convert an integer to string in java
8 Methods To Convert An Integer To String In Java
April 1, 2025 - Let’s see how to use StringBuilder methods to convert int to String in Java. ... public StringBuilder append(int i) This method appends the string representation of the int argument to the sequence. Parameters: i: This is an integer.
🌐
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);
🌐
Great Learning
mygreatlearning.com › blog › it/software development › 4 useful methods to convert java int to string with examples
4 Useful Methods to Convert Java Int to String with Examples
July 28, 2025 - Just add + to empty string and int or any number will be converted to String. Shortcut method but does the job for sure. For simple cases - yes, it works: If you're just looking for quick things like logging a value or debugging, the "" + number ...
🌐
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 binary = Integer.toBinaryString(10); // "1010" String octal = Integer.toOctalString(8); // "10" String hex = Integer.toHexString(255); // "ff" String base36 = Integer.toString(35, 36); // "z" String signed = Integer.toString(-255, 2); // "-11111111" String unsignedHex = Integer.toHexString(-1); // "ffffffff" String unsignedDec = Integer.toUnsignedString(-1); // "4294967295" For fixed-width hex output, such as color codes or checksums, HexFormat (Java 17) pads to 8 digits for an int.
🌐
Vultr Docs
docs.vultr.com › java › examples › convert int type variables to string
Java Program to convert int type variables to String
November 25, 2024 - Define an integer value. Concatenate it with an empty string to get a string result. ... By concatenating number with an empty string, Java automatically converts the integer to a string.