Posts Tagged typecast

Java – Convert String into short

Sunday, July 12th, 2009

String can be converted into short in java by parseShort() method. Type casting is a method to change string to short.

Example of converting string to short

public class StringToShortConvert {

    public static void main(String[] args) {

        String string_to_Short="1234";

        short shrt=Short.parseShort(string_to_Short);

        System.out.println("Type cast string to short :"+shrt);
    }
}

Output

Type cast string to short :1234