Skip to Content

Convert short primitive to Short object Example

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

Advertisement: