How to Convert Java Int to String

By | 2018-03-16T03:32:07+05:30 May 1st, 2016|java|

In this tutorial, I am going to show to different ways to convert Java int to String.

Convert Java Int to String :

We can convert the Java Int to String on 6 different ways; those are listed below

1) Int to String – Integer.toString() :

int number = 895;
String str = Integer.toString(number);

2) Int to String – String.valueOf() :

int number = 895; 
String str = String.valueOf((number);

3) Int to String – new Integer().toString() :

int number = 895; 
String str = new Integer(number).toString();

4) Int to String – String.format (“%d”, number):

int number = 895; 
String str = String.format ("%d", number);

5) Int to String – StringBuffer:

int number = 895; 
StringBuffer sb = new StringBuffer();
sb.append(number);
String str = sb.toString();

You can simply append the “” (double quotes) to your int.

6) Int to String – Appending “”+:

int number = 895; 
String str = ""+number;

Happy Learning 🙂

About the Author:

Hi Folks, you have reach this so far, that shows you like what you are learning. Then why don't you support us to improve for bettor tutorials by leaving your valuable comments and why not you keep in touch with us for latest updates on your favorite blog @ facebook , twitter , Or Google+ ,

Leave A Comment