*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes assert Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "assert" Watch "assert" New topic
Author

assert

J Brewer
Ranch Hand

Joined: Jul 10, 2006
Posts: 46
With the following code:



When I run the following code, it compiles but I get the AssertionError, as expected. However, "String" does not output, as the K&B book woud suggest. So, do I have it correct when I think that, in this example, if the assert expression results in true, then "String" and "well well" are both output, but if the expression results in false, then neither print out and I automatically get an Assertion Error?
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
The way you have it set up, you end the assert statement with the semicolon, and the SOP line is just another line.

You need to have a : after the assert condition, but you can't have a void method after the :.

You can do this.

J Brewer
Ranch Hand

Joined: Jul 10, 2006
Posts: 46
Thankyou, thankyou. I did not even notice my syntax error. Everything is running as it should now.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: assert