I have posted this elsewhere, no solution yet, so posting it here as well. The below mentioned code is not throwing an assertion error as I expected it to since num is less than 5. Hope someone can advise. Thank you.
public class Wrong {
public static void main(String[] args) {
Wrong wrong = new Wrong();
wrong.methodE(3);
}
//AssertionError
void methodE(int num)
{
assert(num>5);
}
}
I guess you forgot to enable assertions.
Run the jvm with the
-ea
argument.you should also consider to provide an assertion error message, e.g.