Syntax error Convert short to String in Java

Convert short to String in Java



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
Updated on: 2020-06-26T06:28:00+05:30

5K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements