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
Discussions

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
Convert string to int?
Thank you all for helping me! You all rock! More on reddit.com
🌐 r/java
16
0
September 11, 2014
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
🌐
GeeksforGeeks
geeksforgeeks.org › java › how-to-convert-string-to-int-in-java
String to int in Java - GeeksforGeeks
The most common method to convert a string to a primitive int is Integer.parseInt(). It throws a NumberFormatException if the string contains non-numeric characters. ... // Java Program to demonstrate // String to int conversion using parseInt() ...
Published: July 23, 2025
🌐
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 class data members types though we have the concept of Wrapper classes to Strings because in practical programming in java we deal with strings. Converting Integers to Strings involves using the Integer classes toString() or String.valueOf() for direct conversion.
🌐
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)
Sometimes you need to convert a number to a string because you need to operate on the value in its string form. There are several easy ways to convert a number to a string: int i; // Concatenate "i" with an empty string; conversion is handled for you.
Find elsewhere
🌐
Study.com
study.com › business courses › business 104: information systems and computer applications
How to Convert String to Int in Java - ParseInt Method - Lesson | Study.com
January 9, 2023 - Since we're trying to convert a non-numeric number to numeric, the exception will be a NumberFormatException in the Java compiler. The code to wrap the pareseInt() function in a try and catch block is displayed here: String myString = newString("hello"); try { int makeNumber = Integer.parseInt(myString); System.out.println(makeNumber); } catch (NumberFormatexception e) { System.out.println("That wasn't a number!"); }
🌐
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 - In this article, I show you how to convert an int into a String in Java the fastest way. The answer is probably surprising for some. I present four variants and measure and compare their speed using JMH microbenchmarks. I analyze the measurement results looking at the Java source code and also the generated bytecode.
🌐
Sentry
sentry.io › sentry answers › java › how do i convert a string to an int in java?
How do I convert a String to an int in Java? | Sentry
How can I convert a String to an int in Java? The two easiest ways to convert a string to an integer in Java are to use Integer.parseInt() or Integer.valueOf(). Here is an example of each.
🌐
Baeldung
baeldung.com › home › java › java string › convert string to int or integer in java
Convert String to int or Integer in Java | Baeldung
December 15, 2023 - In this article we will show multiple ways of converting a String to an int or Integer.
🌐
Educative
educative.io › answers › how-to-convert-an-integer-to-a-string-in-java
How to convert an integer to a string in Java
The first argument is any string containing %d. The second argument is the integer you want to convert. This method will replace %d with your integer.
🌐
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.
🌐
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 - In this article we are going to discuss converting int (primitive type) and Object type (wrapper) Integer to String and vice versa. There are many ways to do it in Java
🌐
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!

🌐
IONOS
ionos.com › digital guide › websites › web development › java string to int
How to convert a string to int in Java - IONOS
January 2, 2025 - parseInt() is a static method that belongs to the Integer class and returns the numerical value of the complex data type string in the form of the primitive data type int. Its syntax looks as follows: ... Let’s look at an example.
🌐
Reddit
reddit.com › r/java › convert string to int?
r/java on Reddit: Convert string to int?
September 11, 2014 -

I'm creating a program of a "yes or no" quiz. At the end, the program is supposed to add up the number of yes and nos and give a result that corresponds to the total.

Example: If someone answered yes for all six questions, that would equal '6'. If someone answer yes four times and no twice, that would equal '4'.

I have the program looking pretty good. But I do have one problem that I can't figure out.

When a questioned is asked, the user types in 'yes' or 'no'. I need the yes to convert to 1 and the no to convert to 0 for the program to work.

I need a way to convert the user entry 'yes' or 'no' to '1' and '0', respectively.

Anyone know how to get this to work or point me in the right direction?

🌐
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(...
🌐
W3Schools
w3schools.com › java › java_strings_numbers.asp
Java Numbers and Strings
Java uses the + operator for both addition and concatenation. Numbers are added. Strings are concatenated. If you add two numbers, the result will be a number: int x = 10; int y = 20; int z = x + y; // z will be 30 (an integer/number) ...
🌐
YouTube
youtube.com › talented developer
3 Ways to Convert Int to String in Java | Convert Integer to String in Java - YouTube
Convert Integer to String in Java: In this video, you will learn how to convert Int to String in Javausing different ways.video time details :Integer.toStrin...
Published: January 9, 2021
Views: 42K
🌐
Scaler
scaler.com › home › topics › array to string in java
Array to String In Java | Scaler Topics
June 2, 2024 - In Java programming language, an array is a data structure that stores the same type of value in a contiguous memory location which we can access using the index, whereas a string is an object that stores a sequence of characters, so there can be some situation where we want to convert an array to string, so for this we have some methods like toString, StringBuilder append, etc.