Java - String valueOf() Method
The Java string valueOf() method returns the string representation of the int argument.
Syntax
public static String valueOf(int i)
Parameters
i |
specify an int. |
Return Value
Returns a string representation of the int argument.
Exception
NA.
Example:
In the example below, valueOf() method returns the string representation of the given argument.
import java.lang.*; public class MyClass { public static void main(String[] args) { int x1 = 125; System.out.println(String.valueOf(x1)); int x2 = -125; System.out.println(String.valueOf(x2)); } }
The output of the above code will be:
125 -125
❮ Java.lang - String