This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes assertion Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "assertion" Watch "assertion" New topic
Author

assertion

anushree ari
Ranch Hand

Joined: Sep 30, 2002
Posts: 98
Is it possible to enable or disable the assertion form the source code itself?
explain me,
thx


anushree
Dan Chisholm
Ranch Hand

Joined: Jul 02, 2002
Posts: 1865
You can disable the program if assertions are not enabled using something like the following.

If assertions are not enabled the assertsEnabled boolean remains false and the RuntimeException is thrown.


Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="http://www.danchisholm.net/" target="_blank" rel="nofollow">Try my mock exam.</a>
Manish Hatwalne
Ranch Hand

Joined: Sep 22, 2001
Posts: 2578

Assertions can be enabled or disabled programmatically, have a look at ClassLoader class documentation.
HTH,
- Manish
Albert Lee
Greenhorn

Joined: Aug 04, 2002
Posts: 18
you can use // or /* */ to disable assersion statement.


Everyday create your history.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: assertion
 
Similar Threads
Assertion is not in beta ...
asseertion
Assertion
Assertion
A assertions qustion help about Man's mock!