Java Short parseShort() methodThe parseShort() method of Java Short class is used to parse the string argument as a signed decimal short. SyntaxParametersx: A String containing the short representation to be parsed. The all characters in the string must be in decimal digits. Return valueIt returns short value represented by the argument in decimal. ExceptionIt throws NumberFormatException, if the string does not contain a parsable short. Example 1Output: String 100 , parse value into parseShort =100 Example 2Output: String -500 , parse value into parseShort =-500 Example 3Output: NumberFormatException Screenshort: Java Short parseShort(String x, int radix) methodThe parseShort(String x, int radix ) method of java Short class is used to parse the string argument as a signed short in the radix specified by the second argument. SyntaxParametersx:A string containing the short to be parsed. radix: radix to be used while parsing string contain short value. Return valueIt return short represented by the string argument in the specified radix. ExceptionIt throws NumberFormatException if:
Example 4Output: String 100 parsed specified by radix 2 , into signed decimal short = 4 Example 5Output: NumberFormatException Screenshort: Example 6String length is Zero Output: NumberFormatException Screenshort: Example 7Output: String parsed specified by radix into signed decimal short = 35 Next TopicJava stringbuffer deletecharat method |