Convert short to String in Java

Convert short to String in Java Example describes about Convert short to String in Java.

Short class helps to wrap the primitive type value of short in an object.

In addition, It also provides several utility  methods which helps the conversion of short to String and String to short

When you need to Convert short to String in Java, we can use Short.toString(short d) method of Short class, It will convert the short to String.

If you need an Short object in lieu of primitive short, you need to use Short.valueOf(short d) method. This will convert the short primitive to Short Object

Convert short To String In Java

public class ConvertShortToString {

 
public static void main(String[] args) {
  
   
short s = 20;
  
   
// convert short to String type
   
System.out.println(Short.toString(s));
  
   
// convert short primitive to Short type
   
System.out.println(Short.valueOf(s));
  
 
}
}
Output
20

20








Your email address will not be published. Required fields are marked *