Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Question w.r.t Assertions" Watch "Question w.r.t Assertions" New topic
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: 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
Wanderer
Sheriff

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: http://aspose.com/file-tools
 
subject: Question w.r.t Assertions
 
Similar Threads
assertion doubt
K&B "assert " explanation
doubt in assert...
assertion doubt
Assertion Doubt.