The assert Statement in Java


Assertions are used for debugging purposes, throwing an AssertionError if the condition is false. Enable assertions with the -ea JVM option.

Source Code

int age = 15;
assert age >= 18 : "Cannot vote";
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments