Google Guava is a java library with lot of utilities and reusable components. This requires the library guava-10.0.jar to be in classpath. The following example shows using Longs.compare() API.
package com.bethecoder.tutorials.guava.primitive_tests; import com.google.common.primitives.Longs; public class LongCompareTest { /** * @param args */ public static void main(String[] args) { System.out.println(Longs.compare(6L, 2L)); System.out.println(Longs.compare(2L, 6L)); System.out.println(Longs.compare(4L, 4L)); } }
1 -1 0