Convert short to String in Java

Java 8Object Oriented ProgrammingProgramming

The valueOf() method is used in Java to convert short to string.

Let’s say we have the following short value.

short val = 20;

Converting the above short value to string.

String.valueOf(val);

Example

 Live Demo

public class Demo {
   public static void main(String[] args) {
      short shortVal = 55;
      // converting short to String
      String str = String.valueOf(shortVal);
      System.out.println("String: "+str);
   }
}

Output

String: 55
raja
Published on 07-Dec-2018 09:59:19
Advertisements