wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes K&B doubt - p371, question about assumption remark Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "K&B doubt - p371, question about assumption remark" Watch "K&B doubt - p371, question about assumption remark" New topic
Author

K&B doubt - p371, question about assumption remark

Ronald Schild
Ranch Hand

Joined: Jun 09, 2008
Posts: 117
Howdy,

I was wondering if the comment "x must be 2" was intended to be a wrong assumption or not, in:



on page 371 in K&B (as x being say, 3, and y being false reaches it). I would have understood it if a later example would have used the snippet with a real assertion ( assert( x == 2) ; ) to prove that the assumption was wrong. But it doesn't, and the example seems to illustrate solely that sometimes we are used to put assumptions in comments.

Just checking, sorry for horrible nitpicking.
[ July 08, 2008: Message edited by: Ronald Schild ]

Java hobbyist.
Jelle Klap
Bartender

Joined: Mar 10, 2008
Posts: 1753
    
    7

Nice catch
I think the comment merely intends to illustrate that assumptions can be added to the source code in the form of debug comments.
Of course, as you said, the assumption is faulty in this case - and I can't imagine it was meant to be. Seeing as the text following the code snippet never refers back to it in trying to prove the debug comment wrong using the assertion mechanism.


Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: K&B doubt - p371, question about assumption remark
 
Similar Threads
Can you make java program into GUI?
the world's smallest number?
Compare string to a String in array
if condition problem ( ex from k&b )
determine least number of keypress