Online Java Compiler By
JavaTpoint.com
public class JavaLongcompareExample1 { public static void main(String[] args) { Long s1 = 76l; Long s2 = 42l; int obj = Long.compare(s1, s2); if(obj==0) { System.out.println("Both the long values are same."); } else if(obj>0) { System.out.println("The value '"+s1+"' is greater than "+s2); } else { System.out.println("The value '"+s1+"' is smaller than "+s2); } } }
Output