Javatpoint Logo
Javatpoint Logo

Java Convert int to String

We can convert int to String in java using String.valueOf() and Integer.toString() methods. Alternatively, we can use String.format() method, string concatenation operator etc.

Java Convert int to String

Scenario

It is generally used if we have to display number in textfield because everything is displayed as a string in form.


1) String.valueOf()

The String.valueOf() method converts int to String. The valueOf() is the static method of String class. The signature of valueOf() method is given below:

Java int to String Example using String.valueOf()

Let's see the simple code to convert int to String in java.

Let's see the simple example of converting String to int in java.

Test it Now

Output:

300
200100

2) Integer.toString()

The Integer.toString() method converts int to String. The toString() is the static method of Integer class. The signature of toString() method is given below:

Java int to String Example using Integer.toString()

Let's see the simple code to convert int to String in java using Integer.toString() method.

Let's see the simple example of converting String to int in java.

Test it Now

Output:

300
200100

3) String.format()

The String.format() method is used to format given arguments into String. It is introduced since Jdk 1.5.

Java int to String Example using String.format()

Let's see the simple code to convert int to String in java using String.format() method.

Test it Now

Output:

200





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA