Java Number shortValue() MethodThe shortValue() method of Java Number class returns the value of the specified number as a short type after a primitive conversion. Syntax:Following is the declaration of shortValue() method: Parameter:
Returns:The shortValue() method returns the numeric value represented by this object after conversion to type short. Exceptions:NA Compatibility Version:Java 1.1 and above Example 1Test it NowOutput: Output Value = 8311 Output Value = 28482 Example 2Test it NowOutput: -92 53 23454 -7753 Example 3Output: Enter the desired Input: -12345ABCD Exception in thread "main" java.util.InputMismatchException at java.base/java.util.Scanner.throwFor(Scanner.java:939) at java.base/java.util.Scanner.next(Scanner.java:1594) at java.base/java.util.Scanner.nextInt(Scanner.java:2258) at java.base/java.util.Scanner.nextInt(Scanner.java:2212) at myPackage.NumberShortValueExample3.main(NumberShortValueExample3.java:9) Next TopicJava Number Class |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India