toString function override
919658Feb 23 2012 — edited Feb 23 2012I am trying to override toString function as follows:
public void toString()
{
(isMale() ? "male " : "female ") + "elephant"
}
I want it to display the output of:
"male elephant" or "female elephant" based on the whether the boolean isMale is true or false. If it is true it would be the first option.
I keep getting the error:
Error: <identifier> expected
Thanks for any help I can get.