Online Java Compiler By
JavaTpoint.com
public class JavaByteCompareToExample1 { public static void main(String[] args) { Byte byte1=127; Byte byte2=67; //It compares two Byte objects numerically int val=byte1.compareTo(byte2); if(val==0){ System.out.println(byte1+" and "+byte2+" values are equal."); } else if(val>0){ System.out.println(byte1+" is greater than "+byte2+" ."); } else{ System.out.println(byte2+" is greater than "+byte1+" ."); } } }
Output