Convert an int value to String: Integer.toString(i) : Convert to String « Data Type « Java






Convert an int value to String: Integer.toString(i)

 

public class Main {
  public static void main(String[] args) {
    int i = 50;

    String str = Integer.toString(i);
    System.out.println(str + " : " + Integer.toString(i).getClass());

  }
}
//50 : class java.lang.String

   
  








Related examples in the same category

1.Use toString method of Integer class to conver Integer into String.
2.Convert an int value to String: new Integer(i).toString()
3.Convert an int value to String: concatenate string to an int value
4.Convert from integer to String
5.Convert a byte array to a Hex string
6.To catch illegal number conversion, try using the try/catch mechanism.
7.The Value of a String with String.valueOf method