Convert Short into String in Java

Java 8Object Oriented ProgrammingProgramming

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.


 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);


Short: 55
String: 55
Published on 12-Nov-2018 17:00:34