Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Simple question on assertion

 
Veena Pointi
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
  • 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 ]
 
Sarma Lolla
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happends if you compile it using -source 1.4 switch?
 
Marlene Miller
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
  • 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.
 
Jonas Isberg
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic