Convert Short into String in Java


Using toString() method to convert Short to string. Firstly, let us take a short primitive datatype and initialize a short value.

short myShort = 55;

Now let us include this value to the following Short object.

Short s = new Short(myShort);

Convert the above given Short to string using the toString() method as shown in the complete example below.

Example

 Live Demo

public class Demo {
   public static void main(String []args) {
      short myShort = 55;
      Short s = new Short(myShort);
      System.out.println("Short: "+s);
      String myStr = s.toString();
      System.out.println("String: "+myStr);
   }
}

Output

Short: 55
String: 55

Updated on: 26-Jun-2020

136 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements