Java Short decode() MethodThe decode() method of Java Short class is used to decode a string into Short. It accepts decimal, hexadecimal and octal numbers. If we put other than this in string then this method will throw Exception. SyntaxParametersX: An encoded String which will be decoded into Short. ExceptionIf input argument "String x" does not contain parsable short then it will throw following exception: throws NumberFormatException Return valueThe decode() method will return Short object that holds short value represented by X. Example 1: (Decimal Number in String input)Test it NowOutput: decoded String value in to Short = 38 Example 2: (Octal Number in String input)Test it NowOutput: decoded String value in to Short = 8 Example 3: (Hexa Number in String input)Test it NowOutput: decoded String value in to Short = 15 Example 4: (Wrong Input, will throw Exception)Test it NowOutput: java.lang.NumberFormatException
Next TopicJava Short
|