How to convert Int to String in Java?

In this article we are going to learn about how to convert int to string in java. It is necessary to know type conversion because, when a number is converted to string it is useful for many easy manipulation.

In this you will find all the ways to convert int to string in java and at end of article you will find code containing all learned methods.

Integer.toString(int num)

It is one of best method to remember, because toString() has ability to convert any data type to string representation. It is also used to provide the string representation of entire class in default way and if you want to retrieve in your wish, then you can override that method and we will discuss about this later on another topic.


public static String toString(int num)

Parameters

num, a integer 

Returns

string representation of any data type


valueOf(int num)

It is also another best method which has ability to covert to any data type. valueOf() returns string containing a number.


public static String valueOf()

Parameters

num - a int

Returns

a string representation of a number

3) Another easiest way to convert int to string is by simply adding double quotes("") to that int and storing it as a String object.

Below code contains all learned methods in this post.

Please let us know your views in comment section.

Related Articles

How to convert String to Int in Java?
Visit this page for all Java Conversions 


Comments

Popular posts from this blog

First Unique Character in a String

Balanced Binary Tree

Majority Element

Smallest Range II