• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question w.r.t Assertions

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 .
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic