English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Java Program to Convert int Value to String

To convert an int value to a String, please usetoString()The following two ways use the method.

Method1

Example

public class Demo {
   public static void main(String args[]) {
      int val = 10;
      String str = Integer.toString(val);
      System.out.println("String: "+str);
   }
}

Output Result

String: 10

Let's look at another example.

Method2

Example

public class Demo {
   public static void main(String args[]) {
      int val = 5;
      String str = new Integer(val).toString();
      System.out.println("String: "+str);
   }
}

Output Result

String: 5