Integer shortValue() Method in Java Last Updated : 05 Dec, 2018 Suggest changes Share Like Article Like Report 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 it to type short. Below programs illustrate the Integer.shortValue() method: Program 1: For positive integers. Java // Java program that demonstrates // Integer.shortValue() method import java.lang.*; public class Geeks { public static void main(String[] args) { Integer sh_object = new Integer(763); // It will return the value of this Integer as a short type short sh_value = sh_object.shortValue(); System.out.println(" The Value of sh_value = " + sh_value); } } Output: The Value of sh_value = 763 Program 2: For negative number. Java // Java program that demonstrates // Integer.shortValue() method import java.lang.*; public class Geeks { public static void main(String[] args) { Integer sh_object = new Integer(-43); // It will return the value of this Integer as a short type short sh_value = sh_object.shortValue(); System.out.println(" The Value of sh_value = " + sh_value); } } Output: The Value of sh_value = -43 Program 3: For a decimal value and string. Note: It returns an error message when a decimal value and string is passed as an argument. Java // java program that demonstrates // Integer.shortValue() method import java.lang.*; public class Geeks { public static void main(String[] args) { // passing a decimal value Integer sh_object = new Integer(27.51); short sh_value = sh_object.shortValue(); System.out.println(" The Value of sh_value = " + sh_value); // passing a string Integer sh_object2 = new Integer("51"); short sh_value2 = sh_object2.shortValue(); System.out.println(" The Value of sh_value2 = " + sh_value2); } } Output: prog.java:10: error: no suitable constructor found for Integer(double) Integer sh_object = new Integer(27.51); ^ constructor Integer.Integer(int) is not applicable (argument mismatch; possible lossy conversion from double to int) constructor Integer.Integer(String) is not applicable (argument mismatch; double cannot be converted to String) 1 error A ankita_chowrasia Follow 0 Article Tags : Java Java-lang package Java-Functions Java-Integer Explore Java BasicsIntroduction to Java3 min readJava Programming Basics9 min readJava Methods6 min readAccess Modifiers in Java4 min readArrays in Java7 min readJava Strings8 min readRegular Expressions in Java3 min readOOP & InterfacesClasses and Objects in Java9 min readAccess Modifiers in Java4 min readJava Constructors4 min readJava OOP(Object Oriented Programming) Concepts10 min readJava Packages7 min readJava Interface7 min readCollectionsCollections in Java12 min readCollections Class in Java13 min readCollection Interface in Java4 min readIterator in Java5 min readJava Comparator Interface6 min readException HandlingJava Exception Handling6 min readJava Try Catch Block4 min readJava final, finally and finalize4 min readChained Exceptions in Java3 min readNull Pointer Exception in Java5 min readException Handling with Method Overriding in Java4 min readJava AdvancedJava Multithreading Tutorial3 min readSynchronization in Java10 min readFile Handling in Java4 min readJava Method References9 min readJava 8 Stream Tutorial7 min readJava Networking6 min readJDBC Tutorial5 min readJava Memory Management4 min readGarbage Collection in Java6 min readMemory Leaks in Java3 min readPractice JavaJava Interview Questions and Answers15+ min readJava Programs - Java Programming Examples7 min readJava Exercises - Basic to Advanced Java Practice Programs with Solutions5 min readJava Quiz1 min readJava Project Ideas For Beginners and Advanced15+ min read My Profile ${profileImgHtml} My Profile Edit Profile My Courses Join Community Transactions Logout Like