How to programmatically test if assertions are enabled?
assertion, java, ocpjp, scjp
Solution
I use this
boolean assertOn = false;
// *assigns* true if assertions are on.
assert assertOn = true;
I am not sure this is the "official" way.
Problem
One of the correct answers from OCP Java SE 6 Programmer Practice Exams is: You can programmatically test wheather assertions have been enabled without throwing an `AssertionError`. How can I do that?