Java Short compareUnsigned() MethodThe CompareUnsigned() method of Java Short class is used to compare two Short values numerically and treat every Short value as unsigned. This method is added since jdk 1.9. SyntaxParametersIt takes to Short type argument. X: First Short value to compare Y: Second Short value to compare Return value
Example 1if unsigned Value of Short x equals to value of Short y. Test it NowOutput: when s1= 60 and s2= 60 is Same then result : 0 Example 2if unsigned value of Short x is less than to the value of Short y. Test it NowOutput: when s1= 70 is less than s2= 90 , then result : -20 Example 3if unsigned value of Short x is greater than to the value of Short y. Test it NowOutput: when s1=70 is greater than s2=60 , then result: 10
Next TopicJava Short
|