Categories
java

Worst toString() Ever…

I think I just wrote the single worst toString(), ever!

public String toString() {
if (this != null)
return “**** implement me”;
return “i am null”;
}

Heck, it’s late Friday evening. I’m in a hurry…. Get over it…. I will obviously fix this, but I’m still disgusted I’m using it.

Can you throw out something worse?

Ok, back to work.

5 replies on “Worst toString() Ever…”

You should check out the commonclipse plugin for eclipse. It’s free, and it will automatically generate toString, hashCode, compareTo, and equals methods for you. Very handy if you’re doing Spring/Hibernate stuff. (Be careful though you can run into some problems if any of those methods make use of lazily-loaded collections.)

Leave a Reply

Your email address will not be published. Required fields are marked *