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)
More Related Contents:
- What’s the best way to check if a String represents an integer in Java?
- Determine if a String is an Integer in Java [duplicate]
- Why is 08 not a valid integer literal in Java?
- How can I prevent java.lang.NumberFormatException: For input string: “N/A”?
- How can I format a String number to have commas and round?
- Format file size as MB, GB, etc [duplicate]
- Converting an int to a binary string representation in Java?
- Java int to String – Integer.toString(i) vs new Integer(i).toString()
- Java: How to split a string by a number of characters?
- Splitting String and put it on int array
- Replace a character specific number of times in String Java
- Java; Initializing A Count of Input, After Period Is Entered
- Difference between String replace() and replaceAll()
- Splitting a string at every n-th character
- Extract digits from a string in Java
- How do I convert a String to an InputStream in Java?
- How to check if two words are anagrams
- Java String to SHA1
- Why does String.replace not work? [duplicate]
- Use of the String(String) constructor in Java [duplicate]
- Why does appending “” to a String save memory?
- Convert a string to a GregorianCalendar
- Is Java’s assertEquals method reliable?
- How to convert String object to Boolean Object?
- Java String ReplaceAll method giving illegal repetition error?
- Using DocumentFilter.FilterBypass
- Comparing a string with the empty string (Java)
- Java Scanner class reading strings
- Create a SortedMap in Java with a custom Comparator
- Java – How to visually center a specific string (not just a font) in a rectangle