• 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

Error in code when using assertion

 
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Now when I tried to compile it this error is coming. I don't know what is its meaning.

A.java:11: warning: as of release 1.4, assert is a keyword, and may not be used
as an identifier
assert j == 2;
^
A.java:11: ';' expected
assert j == 2;
^
1 error
1 warning

I posted this in the beginners form and
I got an answer from Mr. Bastin
Hi Hemant,

While compiling, use "-source 1.4" option.

For Example: If your filename is Abcd.java, compile as
"javac -source 1.4 Abcd.java". You will get the compilation right.


---------------
SCWCD ....ticking.....
SCJP [91%]
---------------

Now how to do this inside an eclipse?

Thanks
Hemant Agarwal
[ February 23, 2006: Message edited by: Hemant Agarwal ]
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In the compiler preferences, disable "default compliance settings" and set the "source compatibility" to 1.4.
 
Hemant Agarwal
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My problem has been solved.
Thanks
 
reply
    Bookmark Topic Watch Topic
  • New Topic