Java toString () method
valueOf () method returns the Number object value to a string.
If the method uses native data type as a parameter and returns String object value native data types.
If the method has two parameters, the first parameter returns a string representation of the base by the second argument specifies the representation.
grammar
In the String class, for example, the method has the following syntax:
String toString() static String toString(int i)
parameter
i - an integer to be converted.
return value
toString (): String Returns the object Integer values.
toString (int i): Specifies the int Returns the String object.
Examples
public class Test{ public static void main(String args[]){ Integer x = 5; System.out.println(x.toString()); System.out.println(Integer.toString(12)); } }
Compile the above program, the output is:
5 12