• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

assertions

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. The assert system is suitable as a general replacement for the try/catch clause.
2) The assert system is suitable as a general replacement for the if/else clause
Both the above statements are false. WHy ? I thought both sounded true
 
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The answer is false because you can turn assertions off. You should never depend on assertions to make your program run -- they should be used during development to insure that unexpected situatioins / variable values do not occur. They are generally turned off in production (it speeds things up). So if you write your code so that it only works if Assertions are turned on... and someone goes and turnst them off... You're in a world of hurt.
Check out these two articles in the JavaRanch Newsletter, hopefully they'll give you a better understanding of the correct usage of assertions:
Cindy's Segment - Asserting Yourself in Public by Cindy Glass
Assertions - Debugging in J2SE 1.4 by Thomas Paul
Enjoy!
[ August 15, 2003: Message edited by: Jessica Sant ]
 
Jui Mahajan
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks. That was good help
 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You may also like
http://java.sun.com/j2se/1.4.1/docs/guide/lang/assert.html
http://www.fawcette.com/javapro/2002_11/online/assert_jstreet_11_14_02/
http://javaboutique.internet.com/tutorials/assertions/
- Dave
----------------
Considering the Certified Java Programmer Exam?
Get JCertify 7.0!
New integration with Beanshell
Integrated context sensitive explanations and content from
Eckel, Baldwin, and Green
http://www.enterprisedeveloper.com/jcertify
 
It will give me the powers of the gods. Not bad for a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic