How to Convert String to Short in Java


Here you may see how to convert a String object to a Short object in Java.

Source Code

package com.beginner.examples;

public class String2ShortExample {

    public static void main(String[] args){
    	String str = new String("14");
        //String converted to short
        short sp = Short.parseShort(str);
        System.out.println(sp);
    }
}

Output:

14
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments