Hi Jim
You can think assert of assertion error invoking keyword if the required condition is not met. Let's consider a scenario: We have 52 playing crads in all. Now you may wish to check this in a program that whether the
cards are infact 52 or not. eg. assert cards==52; now if the
cards are equal to 52 it's OK else an error would be thrown at runtime when this statement is encountered. Provided that exceptions are enabled at runtime.
I wonder if anyone here can imagine a situation where it might not be true, hmmm?
Secondly assert false; will make an assert statement to throw an assertion.
Or
Consider this : assert 2<0; would also be false.
Or were you asking a situation where assert is not a keyword.
Consider this:
boolean assert = false;
if(assert) { throw new RuntimeException(); }
For versions before 1.4 ( excluding 1.4) assert was not a keyword. So it's OK to do so. But now assert is a keyword hence if assertions are enabled when compiling, an error would be reported.
I guess that now assert is a keyword it should not be used an identifier even if the current compiler you are using is less than 1.4 or you don't intent to use assertions for compilers equal to or greater than 1.4.
[ May 31, 2003: Message edited by: Anupam Sinha ]