This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
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


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Confused about  "assert"" Watch "Confused about  "assert"" New topic
Author

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,
vs
assert is a keyword, only if compiling with assertion enabled.


Objective: SCJP 1.5<br /><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html" 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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Confused about "assert"