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
Java Program implementing XOR on a set of Booleans
Java Program to convert string to integer
Studyopedia Editorial Staff
[email protected]

We work to create programming tutorials for all.

No Comments

Post A Comment