Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

java assert

    public static void main(String[] args) {
        int a = 6;
        assert a != 6 : "a != 6";
    }
//Exception in thread "main" java.lang.AssertionError: a != 6

Foo result = null;
assert result != null;

final int result = a + b;
assert (result - a == b) : "Sum of " + a + " + " + b + " returned wrong sum " + result;
 
PREVIOUS NEXT
Tagged: #java #assert
ADD COMMENT
Topic
Name
5+2 =