Assert/check Smaller Equal Than - Java java.lang

Java examples for java.lang:Assert

Description

Assert/check Smaller Equal Than

Demo Code



public class Main{
    public static void main(String[] argv) throws Exception{
        double number = 2.45678;
        double checkValue = 2.45678;
        String name = "java2s.com";
        checkSmallerEqualThan(number,checkValue,name);
    }//  w  ww.  ja v a  2s.c om
    public static void checkSmallerEqualThan(double number,
            double checkValue, String name) throws AssertionException {
        if (number > checkValue) {
            throw new AssertionException(name + " must be at most "
                    + checkValue);
        }
    }
}

Related Tutorials