Convert int to String in Java



The valueOf() method is used in Java to convert int to string.

Let’s say we have the following int value.

int val = 10;

Converting the above int value to string.

String.valueOf(val);

Example

 Live Demo

public class Demo {
   public static void main(String[] args) {
      int val = 2;
      // converting int to String
      String str = String.valueOf(val);
      System.out.println("String: "+str);
   }
}

Output

String: 2
karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know


Advertisements