• Post Reply Bookmark Topic Watch Topic
  • New Topic

Another assert question.  RSS feed

 
Pat Peg
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have been trying to figure out how this works. I have tried a few examples from this site and others but I am getting some errors. I am not sure what I am missing. I put in this line-

assert false : "Fails";

this is in main and should just print out �Fails� but I get an error-

syntax error on �assert�: assert expected
�assert� should not be used as an identifier, since it is a reserved keyword from source level 1.4 on

Thanks for any help
 
Stuart Gray
Ranch Hand
Posts: 410
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you compiling your code with the 1.5 (or 1.4) switch?

javac -source 1.5 Foo.java
 
Pat Peg
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using 1.5. Perhaps it is a setting in eclipse then?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!