Professional Documents
Culture Documents
Java - Tostring Method: Description
Java - Tostring Method: Description
http://www.tutorialspoint.com/java/number_tostring.htm
Descript ion:
The met hod is used t o get a St ring object represent ing t he value of t he Number Object .
If t he met hod t akes a primit ive dat a t ype as an argument , t hen t he St ring object represent ing t he
primit ive dat a t ype value is ret urn.
If t he met hod t akes t wo argument s, t hen a St ring represent at ion of t he first argument in t he radix
specified by t he second argument will be ret urned.
Synt ax:
All t he variant of t his met hod are given below:
String toString()
static String toString(int i)
Paramet ers:
Here is t he det ail of paramet ers:
i -- An int for which st ring represent at ion would be ret urned.
Example:
public class Test{
public static void main(String args[]){
Integer x = 5;
System.out.println(x.toString());
System.out.println(Integer.toString(12));
}
}