18 Aug Java Program to convert integer to string
The toString() method is used to convert integer to string in Java. The syntax is as follows:
public static String toString(int val)
Here, val is the integer to be converted.
Example 1
Following is an example to convert integer to string in Java:
public class Example
{
public static void main( String args[] )
{
int p = 7;
System.out.println("Integer Value = "+p);
System.out.println("String Value = "+(Integer.toString(p)));
}
}
Output
Integer Value = 7 String Value = 7
Example 2
public class Example
{
public static void main( String args[] )
{
Integer p = new Integer(10);
System.out.println("String = "+p.toString());
}
}
Output
String = 10
No Comments