File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Confused about  Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Confused about  "assert"" Watch "Confused about  "assert"" New topic

Confused about "assert"

P Ventura
Ranch Hand

Joined: Jan 24, 2007
Posts: 42
I can't understand if assert is always a keyword and it can't be used as identifier,
assert is a keyword, only if compiling with assertion enabled.

Objective: SCJP 1.5<br /><a href="" target="_blank" rel="nofollow">API</a><br /> <blockquote><font size="1" face="Verdana, Arial">code:</font><hr><pre><font size="2"><br />Double n1 = Double.NaN; Double n2 = Double.NaN;<br /> n1.equals(n2) // true even though Double.NaN != Double.NaN<br />-0.0 == +0.0; // true<br />Double n1 = -0.0;Double n2 = +0.0;<br />n1.equals(n2) // false even though -0.0 == +0.0<br /></font></pre><hr></blockquote>
Mary John
Ranch Hand

Joined: Sep 17, 2007
Posts: 109
I guess assertion enabling and assertion disable (-ea and -da) is only when executing. ie with java command and not javac compiler options.

checking whether assert has been used as a keyword or as a identifier comes into picture when you compile with javac, and when you use the -source options.

SCJP 5.0<br />SCJD working on it
I agree. Here's the link:
subject: Confused about "assert"
It's not a secret anymore!