| Author |
Question w.r.t Assertions
|
Jeff Hu
Greenhorn
Joined: Feb 03, 2005
Posts: 16
|
|
From my understanding by reading K&B book, I can compile with code that uses "assert" as an identifier, if I use "javac -source 1.3 ..." But when I actually compile code, I still got ============================================== javac -source 1.3 Assert.java Assert.java:7: warning: as of release 1.4, assert is a keyword, and may not be u sed as an identifier int assert = 10; ^ 1 warning Does anyone can explain it in more detail? Thanks in advance!
|
SCJP 1.4, SCJA 1.0
|
 |
ankur rathi
Ranch Hand
Joined: Oct 11, 2004
Posts: 3829
|
|
So whats the big deal . You are just getting warning . I am sure , you are able to execute program . It is just for safety purpose .
|
 |
Jim Yingst
Wanderer
Sheriff
Joined: Jan 30, 2000
Posts: 18670
|
|
|
Is that the first edition of K&B's book? In SDK 1.4, assert was not a keyword unless you compiled using -source 1.4. That is, -source 1.3 was effectively the default. Now under JDK 5.0, by default you get all the features of 5.0 unless you compile with -source 1.4 or -source 1.3. So now, 1.5 is the default. That means that using JDK 5.0, you can't use assert as an identifier unless you specify -source 1.3.
|
"I'm not back." - Bill Harding, Twister
|
 |
 |
|
|
subject: Question w.r.t Assertions
|
|
|