aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes assert Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply 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: 2341
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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: assert
 
Similar Threads
Operator and Assignment Mock Question
Can u explain this assert question
assertion related(mock)
Assert
A question on assert statement from mock exam