How can I programmatically enable assert for particular classes, instead of specifying command line param \"-ea\"?
public class TestAssert {
private sta
The simplest & best way can be:
public static void assertion(boolean condition, String conditionFailureMessage)
{
if(!condition)
throw new AssertionError(conditionFailureMessage);
}
No need to set -ea as VM argument .
call the function like :
assertion(sum>=n,"sum cannot be less than n");
If assertion fails, code will give AssertionError, else code will run safely.