To differentiate two numbers, usually our approach is to make use of if else conditional statements
, and base on the results of the evaluation we determine the which one of the two numbers are greater or if they are equality. The compareTo method were devised as such that we can test the equality or compare two numbers without going the trouble of formulating the conditional statements. Well we might still be using the if condition however the conditional statements are more consistent now since we have only 3 possible values which are 0, <0, and >0.
The compareTo() method and compare() method yield the same result. The only difference is that if you want to just compare two primitive byte datatype without having to convert to Byte object, compare() method is already enough. However if you opt to compare two Byte object, the compareTo() method will do the job better.