71
Java Short compare() Method
The compare() method of Java Short class compares two Short object numerically. Short is wrapper class.
Syntax
Parameters
X: first short value
Y: second short value
Return value
- Return 0, if first short value is equal to second short value (x=y).
- Return less than 0, if first short value less than to second short value (x
- Return more than 0, if first short value greater than to second short value (x>y).
).
Example 1
when “short x = short y”
Output:
Two short values compared result: 0
Example 2
Output:
Two short values compared result: -10
Example 3
Output:
Two short values compared result: 10
Next TopicJava Short