After the colon is an expression. Whatever is represented (returned) by that expression is passed to the constructor of the AssertionError. If you review the API for AssertionError, you'll see that the constructor is overloaded to accept numerous primitive types, as well as Object. This parameter is converted to String for the error message.
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org
The second expression after the colon can be anything which results in a value. It is like system.out.println() where you can pass in a primitive or an object and it will conver to a String representation.
To summarize what I put after a colon has to return a value(ie. values of variables, method return), hench void methods cannot work and since System.out.println("") does not return anything also it cannot be used as well. Correct?
Originally posted by Francis Palattao: ...void methods cannot work and since System.out.println("") does not return anything also it cannot be used as well. Correct?
Correct. An expression that returns void cannot be used here.
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org
I am not a spy. Definitely. Definitely not a spy. Not me. No way. But this tiny ad ...
a bit of art, as a gift, the permaculture playing cards