• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

assertions

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
thanks. That was good help
 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • 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
 
Our first order of business must be this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic