This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Assertions 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 "Assertions" Watch "Assertions" New topic
Author

Assertions

janki tangeda
Ranch Hand

Joined: Jun 07, 2005
Posts: 54
assert Expression1:Expression2;

For the above form of assert statement, the Expression2 is required to be a value(either primitive type or reference type).

But in the example below, Expression 2 is a String object(not a reference value of String object).

assert age>0 : "The value of age cannot be negative +"age;

can anybody explain?
Steve Morrow
Ranch Hand

Joined: May 22, 2003
Posts: 657

The result of that expression is a reference to a String object.
janki tangeda
Ranch Hand

Joined: Jun 07, 2005
Posts: 54
What's the result?
Steve Morrow
Ranch Hand

Joined: May 22, 2003
Posts: 657

The result is a reference to a new String object that is the concatenation of "The value of age cannot be negative " (accounting for the typo) and the String value of 'age'.
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Assertions
 
It's not a secret anymore!