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
๐ŸŒ
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 โ€บ 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 - Note: This method is not efficient as an instance of the Integer class is created before conversion is performed. And deprecated and marked as removal. Here, we will declare an empty string and using the '+' operator, we will simply store the resultant as a string. Now by this, we are successfully able to append and concatenate these strings. ... // Java Program to Illustrate Integer to String Conversions // Using Concatenation with Empty String class Geeks { // Main driver method public static void main(String args[]) { // Custom integer values int a = 1234; int b = -1234; // Concatenating with empty strings String str1 = "" + a; String str2 = "" + b; // Printing the concatenated strings System.out.println("String str1 = " + str1); System.out.println("String str2 = " + str2); } }
๐ŸŒ
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 - You can convert variables from one data type to another in Java using different methods. In this article, you'll learn how to convert integers to strings in Java in the following ways: Using the Integer.toString() method. Using the String.valueOf(...
๐ŸŒ
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 - 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. That means if you have int x = 5, just define x + "" and youโ€™ll get your new String.
๐ŸŒ
Sentry
sentry.io โ€บ sentry answers โ€บ java โ€บ how do i convert an integer to a string in java?
How Do I Convert an Integer to a String in Java? | Sentry
In this example, String.valueOf(number) converts the int value, number, to a String. Alternatively, you can use the Integer.toString() method to convert an Integer to 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);
๐ŸŒ
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 convert an int into a string, you have five options. Weโ€™ll introduce each of them to you below. The options are: The method Integer(int).toString from the integer class
Find elsewhere
๐ŸŒ
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 - Learn Java the right way! Our course teaches you essential programming skills, from coding basics to complex projects, setting you up for success in the tech industry. ... This method is the most straightforward, easy and commonly recommended method when you need to convert an int to a String. String.valueOf() is a static method in the String class and is designed for this purpose. This method takes an integer and returns its string form.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ integer-tostring-in-java
Integer toString() in Java - GeeksforGeeks
July 5, 2018 - Example: This example shows how to convert an Integer object into a String using the toString() method in Java.
๐ŸŒ
iO Flood
ioflood.com โ€บ blog โ€บ int-to-string-java
Int to String Java Conversion: Methods and Examples
February 26, 2024 - In this guide, weโ€™ll walk you through the process of converting integers to strings in Java, from the basics to more advanced techniques.
๐ŸŒ
Reddit
reddit.com โ€บ r/javahelp โ€บ converting a number to a string
r/javahelp on Reddit: Converting a Number to a String
August 14, 2022 -

Hey, all. I was working on some Codewars fundamentals and I came across this problem. My solution was accepted and, on the list of acceptable solutions, I see what seems to be an equally useful solution. I just wondered if there's any reason to use one over the other in any particular situation or if they do the same thing all the time. The passed in variable was some integer num.

My solution was:

return Integer.toString(num);

The other solution I saw was:

return String.valueOf(num);

Any insight would be much appreciated. Thanks!

๐ŸŒ
Vultr Docs
docs.vultr.com โ€บ java โ€บ examples โ€บ convert-int-type-variables-to-string
Java Program to convert int type variables to String | Vultr Docs
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.
๐ŸŒ
Initial Commit
initialcommit.com โ€บ blog โ€บ int-to-string-java
Convert Int to String Java
A quick and dirty way to convert a number to string in Java is to simply concatenate the number to an empty string using the + operator. In addition to converting an int to string, this approach can also be used as a quick way to build longer ...
๐ŸŒ
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 - The returned value for both expressions is a Java String that represents the integer โ€œiโ€ argument. If the radix parameter is used, the returned string is specified by the respective radix. Convert Integer to String using Integer.toString().
๐ŸŒ
HappyCoders.eu
happycoders.eu โ€บ java โ€บ how-to-convert-int-to-string-fastest
How to Convert int to String in Java โ€“ The Fastest Way
December 2, 2024 - Extensive benchmark tests have shown that across all Java versions, "" + i is the fastest way to convert an integer to a String.
๐ŸŒ
Programiz
programiz.com โ€บ java-programming โ€บ examples โ€บ int-to-string-conversion
Java Program to convert int type variables to String
Build the coding confidence you need to become a developer companies will fight for ยท Stop copy pasting code you don't actually understand ... Become a certified Java programmer. ENROLL ... Created with over a decade of experience. ... Created with over a decade of experience and thousands of feedback. ... Try Programiz PRO! ... Become a certified Java programmer. Try Programiz PRO! ... class Main { public static void main(String[] args) { // create int variable int num1 = 36; int num2 = 99; // convert int to string // using valueOf() String str1 = String.valueOf(num1); String str2 = String.valueOf(num2); // print string variables System.out.println(str1); // 36 System.out.println(str2); // 99 } }
๐ŸŒ
FavTutor
favtutor.com โ€บ blogs โ€บ int-to-string-java
Convert Int to String in Java using 08 Methods (with code)
December 28, 2022 - Here, in this example, we are using the toBinaryString() method to achieve the same conversion from an integer to a String as shown. ... int a = 1567; int b = -1567; // Concatenating with empty strings String str1 = "" + a; String str2 = "" ...
๐ŸŒ
TestMu AI Community
community.testmuai.com โ€บ ask a question
Convert int to String in Java - TestMu AI Community
February 12, 2025 - How do I convert an int to string in Java? Given a number: int number = 1234; What is the best way to convert this int to string in Java so that the output is: String stringNumber = "1234";