Java Short compareTo() MethodThe compareTo() method of Java Short class compares two Short Objects. It will be used when we compare two Short values numerically to check these two values are equal or not, less than or greater than. SyntaxParametersX: Another Short value, it will be compared Return value
Example 1if Short is equal to argument "Short X" Test it NowOutput: when Short s1=45 & s2=45 (both have same Value ) = 0 Example 2if Short is numerically greater than to argument "Short x" Test it NowOutput: s1=55 & s2=45 (when Short is greater than argument ) = 10 Example 3if Short is numerically less than to argument "Short x" Test it NowOutput: s1=55 & s2=45 (when Short is less than argument ) = -10
Next TopicJava Short
|