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?
I use this
boolean assertOn = false;
// *assigns* true if assertions are on.
assert assertOn = true;
I am not sure this is the "official" way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With