Online Java Compiler By
JavaTpoint.com
public class JavaByteCompareToExample3 { public static void main(String[] args) { //byte value should be in the range between -127 to 128 Byte b1= 567; byte b2=Byte.MIN_VALUE; int val=b1.compareTo(b1); if(val>0){ System.out.println(b1+" is greater than "+b2); } else{ System.out.println(b2+" is greater than "+b1); } } }
Output