What does assert do in Java?

By default assert does nothing, but when assertions are enabled (java -ea) assert throws AssertionError if the condition is false.

Here's how you use it:

// java -ea

int a = 33;

// does nothing
assert a == 32;

// throws AssertionError
assert a == 33;