Skip to Content

Convert Integer to Java String object

  1. /*
  2.   Convert Integer object to String object
  3.   This example shows how a Integer object can be converted into String object.
  4. */
  5.  
  6. public class IntegerToStringExample {
  7.  
  8.   public static void main(String[] args) {
  9.     Integer intObj = new Integer(10);
  10.    
  11.     //use toString method of Integer class to conver Integer into String.
  12.     String str = intObj.toString();
  13.     System.out.println("Integer converted to String as " + str);
  14.   }
  15. }
  16.  
  17. /*
  18. Output of the program would be
  19. Integer converted to String as 10
  20. */