NumberUtils.compare : NumberUtils « Apache Common « Java Tutorial






import org.apache.commons.lang.math.NumberUtils;

public class MainClass {
    public static void main(String[] args) {
        //Compare two double values
        System.out.println("(FIRST > SECOND) >>> " +
            NumberUtils.compare(2.11, 1.11));
        System.out.println("(FIRST < SECOND) >>> " +
            NumberUtils.compare(1.11, 2.11));
        System.out.println("(FIRST == SECOND) >>> " +
            NumberUtils.compare(1.11, 1.11));

    }
}
(FIRST > SECOND) >>> 1
(FIRST < SECOND) >>> -1
(FIRST == SECOND) >>> 0
  Download:  CommonLangNumberUtils.compare.zip( 199 k)







37.9.NumberUtils
37.9.1.NumberUtils.toInt
37.9.2.NumberUtils.max
37.9.3.NumberUtils.isNumber
37.9.4.NumberUtils.isDigits
37.9.5.NumberUtils.createBigDecimal
37.9.6.NumberUtils.compare