That expression is followed by a vertical bar, followed by a condition involving the element variable, r in the example. Employ the exists quantifier when a condition must hold true for at least one element in a collection. Both forall and exists can be applied to different kinds of Java collections. You can also combine the logical operators just introduced to form complex assertions. Suppose class B extends class A .
Class A defines a set of invariants, preconditions, and postconditions.
In that case, the invariants and preconditions of class A apply to class B as well, and methods in class B must satisfy the same postconditions that class A satisfies. You may add more restrictive assertions to class B . The aforementioned mechanism works for interfaces and implementations as well. Suppose A and B are interfaces and class C implements both. In that case, C is subject to invariants, preconditions, and postconditions of both interfaces, A and B , as well as those defined directly in class C .