Short shortValue() Method in Java Last Updated : 05 Dec, 2018 Summarize Comments Improve Suggest changes Share Like Article Like Report The shortValue() is an inbuilt method of the Short class in Java and is used to return the Short value of this value. Syntax: public short shortValue() Parameters: The method does not take any parameter. Return Value: The method returns the numeric value represented by this object after conversion to type short. Below programs illustrate the Short.shortValue() method: Program 1: Java // Java program that demonstrates // Short.shortValue() method import java.lang.*; public class Geeks { public static void main(String[] args) { short svalue = 21; Short sh_obj = new Short(svalue); // It will return the short value of Short short sh_Value = sh_obj.shortValue(); // Printing short value System.out.println("The short value of the given Short is = " + sh_Value); } } Output: The short value of the given Short is = 21 Program 2: Java // java program that demonstrates // Short.shortValue() method import java.lang.*; public class Geeks { public static void main(String[] args) { short svalue = -19; Short sh_obj = new Short(svalue); // It will return the short value of Short short sh_Value = sh_obj.shortValue(); // Printing short value System.out.println("The short value of the given Short is = " + sh_Value); } } Output: The short value of the given Short is = -19 Program 3: Note: It returns an error message when a decimal value and string is passed as an argument. Java // Java program that demonstrates // Short.shortValue() method import java.lang.*; public class Geeks { public static void main(String[] args) { short svalue = 9.6; Short sh_obj = new Short(svalue); // It will return the short value of Short short sh_Value = sh_obj.shortValue(); // Printing short value System.out.println("The short value of the given Short is = " + sh_Value); short svalue2 = "61"; Short sh_obj2 = new Short(svalue2); // It will return the short value of Short short sh_Value2 = sh_obj2.shortValue(); // Printing short value System.out.println("The short value of the given Short is = " + sh_Value2); } } Output: prog.java:10: error: incompatible types: possible lossy conversion from double to short short svalue = 9.6; ^ prog.java:18: error: incompatible types: String cannot be converted to short short svalue2 = "61"; ^ 2 errors Comment More infoAdvertise with us Next Article Number.shortValue() method in java with examples A ankita_chowrasia Follow Improve Article Tags : Java Java-lang package Java-Functions Java-Short Practice Tags : Java Similar Reads Integer shortValue() Method in Java The Integer.shortValue() is an inbuilt method of java.lang which returns the value of this Integer in the short type . Syntax: public short shortValue() Parameters: The method does not take any parameters. Return Value: The method returns the integer value represented by this object after converting 2 min read Java String valueOf() Method The valueOf() method of the String class in Java helps to convert various data types like integers, floats, booleans, and objects into their string representations. It makes it simple to work with string manipulation, logging, and displaying data efficiently.Example:To convert a number into text for 3 min read Number.shortValue() method in java with examples The shortValue() is an inbuilt method in Java from the java.lang.Number class. This method is used to convert the current number object into a short primitive type. This may involve rounding or truncation because the short data type in Java is a 16-bit signed integer with a value range from -32,768 2 min read BigDecimal shortValueExact() Method in Java The java.math.BigDecimal.shortValueExact() is an inbuilt method in java that converts this BigDecimal to a short, checking for lost information. If this BigDecimal has a nonzero fractional part or is out of the possible range for a short result then an ArithmeticException is thrown. Syntax: public s 2 min read Short compare() method in Java The compare() method of Short class is used to compare two primitive short values for numerical equality. As it is a static method therefore it can be used without creating any object of Short. Syntax: public static int compare(short x, short y) Parameters: This method accepts two parameters: x: whi 2 min read Byte shortValue() method in Java with examples The shortValue() method of Byte class is a built in method in Java which is used to return the value of this Byte object as short. Syntax ByteObject.shortValue() Return Value: It returns the value of ByteObject as short. Below is the implementation of shortValue() method in Java: Example 1: Java // 2 min read Like