English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Java Program Converts String to Short Primitive

Using theparseShort()The method converts String to a primitive short. It parses the string argument as a signed short.

Firstly, we set a string.

String str = "99";

Now, we have taken a primitive short and included the string value.

short val = Short.parseShort(str);

The following is an example of converting String to a primitive short.

Example

public class Demo {
   public static void main(String[] args) {
      String str = "99";
      short val = Short.parseShort(str);
      System.out.println(val);
   }
}

Output Result

99