81
Java Byte compare() method
The compare() method of Java Byte class compares the two specified byte values.
Syntax:
Parameters:
The parameters ‘x’ and ‘y’ represent the first and second byte value to be compared.
Return Value
This method returns an integer value.
- It returns zero, if both the parameters are equal(x==y).
- It returns positive one, if x is greater than y(x>y).
- It returns negative one, if x if smaller than y(x<y).
Example 1
Output:
67 is greater than 3 .
Example 2
Output:
Enter your age : 12 Oops! You are not an adult. You can vote after 6 years.
Example 3
Output:
127 is greater than -128
Next TopicJava Byte