Java String valueOf(int i) method example

HQ » Java Tutorial » java.lang » String » valueOf(int i) method example
Java String valueOf(int i) method example 2018-02-19T13:15:31+00:00

java.lang.String valueOf(int i)

Description :

This java tutorial shows how to use the valueOf(int i) method of String class of java.lang package. This method returns a string representation of int data type. This is the same method as Integer.toString(int,int)

Method Syntax :

public static String valueOf(int i)

Parameter Input :

DataType Parameter Description
int i method parameter which we are interested to get the string equivalent

Method Returns :

The String valueOf() method with argument int returns a new String object which corresponds to the string representation of the method argument.

Compatibility Version :

Since the beginning

Exception :


Discussion :

The string valueOf(int i) method is simply to get a String equivalent of int method parameter. This method be statically accessed which means we should call the method like String.valueOf(int i).

Java Code Example :

This example source code demonstrates the use of valueOf(int i) of String class. Below are different examples of getting a value of int. As you would noticed we have used the unboxing functionality to transform an Integer object into primitive int datatype and then get the string equivalent using the valueof method.

Sample Output :

Running the valueOf() method example source code of String class will give you the following output

java string indexOf(int) method example

java string indexOf(int) method example

Exception Scenario :


Suggested Reading List :

References :


Contact Info


Our Goal

JavaTutorialHQ aims to to be The Ultimate Guide on Java with hundreds of examples from basic to advance Topics.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.