This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv 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 REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "assertion" Watch "assertion" New topic


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,

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="" target="_blank" rel="nofollow">Try my mock exam.</a>
Manish Hatwalne
Ranch Hand

Joined: Sep 22, 2001
Posts: 2591

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

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

Everyday create your history.
I agree. Here's the link:
subject: assertion
It's not a secret anymore!