This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Assertion doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Assertion doubt" Watch "Assertion doubt" New topic
Author

Assertion doubt

Ash Gill
Ranch Hand

Joined: Jun 30, 2011
Posts: 71
i am trying to get an assertion error, however, When i compile my program from the command line, the assertion error is never thrown and the program compiles fine



can anyone help to figure out that why isn't the assertion error thrown anywhere in the above code.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Ash Gill wrote:i am trying to get an assertion error, however, When i compile my program from the command line, the assertion error is never thrown and the program compiles fine

AssertionError is a RuntimeException. exception always throws at runtime. so what happend when you run the program with -ea flag? i.e, java -ea YourApp.

note: by default assertion is disabled!
Ash Gill
Ranch Hand

Joined: Jun 30, 2011
Posts: 71
yes, they work fine. thanks a lot. i was getting the concept wrong, good that i tried out an example.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Assertion doubt
 
Similar Threads
Simple question on assertion
doubt :assertion errors
on assertions
Regarding to assertions
Assertion