Logo 
Search:

Java Articles

Submit Article
Home » Articles » Java » FundamentalRSS Feeds

Short Wrapper Class

Posted By: Mohammad Evans     Category: Java     Views: 5618

This article explains about Short wrapper class in java.

Short wrapper class is used to wrap primitive data type short value in an object. 

Examples of Short Wrapper Class

Example 1 : Convert short data type to Short object 

public class shortToShort
{
 
  public static void main(String[] args) 
  {
    short s = 1;
 
    Short sObj = new Short(s);
    System.out.println(sObj);
 
  }
}

Output 
1

This example shows how a short data type value can be converted to short object.

Example 2 : Convert String to Short object 

public class StringToShort
    public static void main(String[] args)   
   {   
        Short s1 = new Short("1");    
        System.out.println(s1);     
        String str = "2";    
        Short s2 = Short.valueOf(str);    
        System.out.println(s2);  
    }

Output
1
2

This example shows how we can convert String object to Short object.
  
Share: 

 
 
 

Didn't find what you were looking for? Find more on Short Wrapper Class Or get search suggestion and latest updates.

Mohammad Evans
Mohammad Evans author of Short Wrapper Class is from London, United Kingdom.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!