Skip to Content

Convert long primitive to Long object Example

  1. /*
  2.   Convert long primitive to Long object Example
  3.   This example shows how a long primitive value can be converted to Long object
  4. */
  5.  
  6. public class longToLongExample {
  7.  
  8.   public static void main(String[] args) {
  9.     long i = 10;
  10.    
  11.     /*
  12.     Use Long constructor to convert long primitive type to Long object.
  13.     */
  14.    
  15.     Long lObj = new Long(i);
  16.     System.out.println(lObj);
  17.    
  18.   }
  19. }
  20.  
  21. /*
  22. Output of the program would be
  23. 10
  24. */

Advertisement:
Join 1000+ fellow learners! Enter your email address below: