• 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

Simple question on assertion

 
Ranch Hand
Posts: 469
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have JSDK1.3 version.But compier is giving following error for my assertion program asert.java...
"asert.java:10: cannot resolve symbol
symbol : class assert
location: class asert
assert a ;"
Here I am pasting the code...

I kept code simple coz , I just wanted to play with assert keyword.
Can anybody please lemme know why is it not taking assert keyword?
Thanks
Veena
Thanks
Veena
[ March 18, 2003: Message edited by: Veena Point ]
 
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What happends if you compile it using -source 1.4 switch?
 
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In 1.3 assert is not a keyword. In your program, assert is a user-defined identifier.
The compiler thinks assert is the name of a class (or interface). You are declaring a variable a of class type assert. However the variable a has already been declared as type boolean.
 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you download java version 1.4, your code should run fine when compiled with:
javac -source "1.4" asert.java
and started with:
java -ea asert
or
java -da asert
-da = disable assertions
-ea = enable assertions
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic