Online Java Compiler By
JavaTpoint.com
public class JavaLongExample1 { public static void main(String[] args) { Long x1=67l; Long x2=98l; Long x3=6l; // Compares two long values. int b1 = Long.compare(x1, x2); if(b1==0) { System.out.println("Both '"+x1+"' and '"+ x2+"' are same"); } else if(b1>0) { System.out.println(x1+" is greater than "+x2); } else { System.out.println(x1+" is smaller than "+x2); } // Returns the hashcode for the given long value. System.out.println("The hashcode for the value '"+x1+"' is given as :"+x1.hashCode()); // Returns the value of long in the form of short. short b2 = x3.shortValue(); System.out.println("The short value for '"+x2+"' is given as : "+b2); } }
Output