Javatpoint Logo
Javatpoint Logo

Java Byte compare() method

The compare() method of Java Byte class compares the two specified byte values.



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

Test it Now


67 is greater than 3 .

Example 2


Enter your age : 12
Oops! You are not an adult. You can vote after 6 years.

Example 3

Test it Now


127 is greater than -128

Next TopicJava Byte

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA