• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Assertion doubt

 
Ash Gill
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Java Windows XP
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, they work fine. thanks a lot. i was getting the concept wrong, good that i tried out an example.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic