• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

assertions doubt

 
Ranch Hand
Posts: 278
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have basic doubts in assertions.


1.
Can we use assert as an identifier in java 1.4 .if we dont enable it .
2. In K &B chap 5 ,pg 378
it says ,with javac -source 1.4 abc.java ,asertions enabled .
but i beleive it means ,telling Compiler to compile or code with 1.4 compiler ,in which assertions are Keywords.
then how is this the way to enable assertions at compile time.
and in java 1.5 ,assertions are always keyworkds.
 
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

From 1.4 assert is a keyword.So irrespective of whether assertions are enabled or not,you cannot use it as an identifier.

To enable assertions
us java -enableassertions or java -ea

Just saying javac -source 1.4 does not enable assertions.

If you use source other than 1.4 or 1.5 alone,you could use assert as an identifier.

Please correct me if am wrong.

Thanks
Praveen SP
reply
    Bookmark Topic Watch Topic
  • New Topic