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 Question w.r.t Assertions 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 "Question w.r.t Assertions" Watch "Question w.r.t Assertions" New topic

Question w.r.t Assertions

Jeff Hu

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 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: 3830
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

Joined: Jan 30, 2000
Posts: 18671
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
I agree. Here's the link:
subject: Question w.r.t Assertions
It's not a secret anymore!