Skip to Content

Convert Long object to String object

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