Javatpoint Logo
Javatpoint Logo

Java Byte compareUnsigned() method

The compareUnsigned() method of Java Byte class compares two byte objects numerically by treating the values as unsigned.



The parameters 'x' and 'y' represent the first and second byte value to compare.

Return Value

This method returns an integer value.

  • It returns zero, if both the parameters are equal(x==y).
  • It returns value greater than zero, if x is greater than y as unsigned values(x>y).
  • It returns value less than zero, if x if smaller than y as unsigned values (x<y).

Example 1

Test it Now


compareUnsigned method will return 1

Example 2

Test it Now


-9 is greater than -10

Next TopicJava Byte

Youtube For Videos Join Our Youtube Channel: Join Now


  • Send your Feedback to

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA