aspose file tools*
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
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.
 
 
subject: Assertion doubt