I edited his code to add the missing code tags and also shortened the long lines (that is how you do it, but it will be much better if you shorten lines as you go). At least the second class wasn't as bad as the first one for long lines. I hope I don't have to edit it again and make it look differentCarey Brown wrote:Please edit your last post to put Code tags around the second block of code. . . . .
Every Object has a toString method. If it isn't an Object then it is null or a primitive, and you can print nulls and primitives, too. You should be able to pass absolutely anything to println and get some sort of output and no Exceptions.Carey Brown wrote:. . . System.out.println( user ); // ASSUMES User HAS A toString() METHOD
All things are lawful, but not all things are profitable.
I meant a useful toString() method.Campbell Ritchie wrote:
Every Object has a toString method. If it isn't an Object then it is null or a primitive, and you can print nulls and primitives, too. You should be able to pass absolutely anything to println and get some sort of output and no Exceptions.Carey Brown wrote:. . . System.out.println( user ); // ASSUMES User HAS A toString() METHOD
Carey Brown wrote:. . . I meant a useful toString() method.
That's a pleasure Whether that includes thanks for advice on the toString method, well, I shall leave you to work that out for yourself.Rain Draken wrote:Thank you for the advice . . .
Crusading Chameleon likes the size of this ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|