The compareTo method of Byte class is used for comparing two Byte objects.
public class ByteWrapper {
public static void main(String[] args) {
Byte b1 = new Byte("10");
Byte b2 = new Byte("10");
int comparedValue = b1.compareTo(b2);
System.out.println(comparedValue);
if (comparedValue == 0){
System.out.println("Both objects are equal");
}
else if (comparedValue > 0){
System.out.println("First object is greater than second object.");
}
else if(comparedValue <0){
System.out.println("First object is less than second object.");
}
}
}
