• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

assertions...

 
Ranch Hand
Posts: 521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can we set assertions programmatically? whizlabs says we can....want to know how?
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes we can:



compile as: $ javac A.java
run as: $ java -ea A
the 'ea' stands for: enable assertions.
if you omit the '-ea' part then 'assert(i >= 5)' will have no effect.
 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

venu chakravorty wrote:Yes we can:



compile as: $ javac A.java
run as: $ java -ea A
the 'ea' stands for: enable assertions.
if you omit the '-ea' part then 'assert(i >= 5)' will have no effect.



However, we still have to enable (-ea) during running for the assertion to have any effect! So, I am not still sure how programmatically you can enable the assertion (if that was the question). But definitely, assertions are disabled at runtime by default
 
Raju Champaklal
Ranch Hand
Posts: 521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i was talking about enabling within the program and not using the command line....
 
Farmers know to never drive a tractor near a honey locust tree. But a tiny ad is okay:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic