Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Anyone tried assert successfully? 1

Status
Not open for further replies.

prosper

Programmer
Sep 4, 2001
631
HK
can you give simple example?
 
assert is available in 1.4 only. By default, it is disabled
at runtime. If you don't specify the source at runtime, then the compiler will complain. Hence, given a file that has "assert" keyword in it, to compile you need to do this:-

javac -source 1.4 testAssert.java

if your old program is using the word assert as a variable name, then to make the compiler NOT complaining about it, do this:-

javac -source 1.3 testAssertNotKeyword.java

how do you enable assertions at runtime?

java -ea testAssert

voila! The need thing about assertion is you can control which package(s) need to have assertion enabled and which one is not.

~za~
You can't bring back a dead thread!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top