views:

123

answers:

2

Hi all...

in my classes when writing the toString() method I always use the ToStringBuilder from org.apache.commons

And when I'm extending other classes I use appendSuper() and then my appends

The question:

Are there are any real differences in doing:

appendSuper(super.toString())

instead of

append(super.toString())

Kind of dummy question.

Cheers

+3  A: 

A ToStringStyle implementation can render it differently when appendSuper is called from append. No implementation of Apache commons lang 2.4 does it.

Thomas Jung
A: 

Quick question why are you using the ToStringBuilder() ? Internally any String declaration you make in java is converted into a StringBuilder. Of course I may be misunderstanding the use of ToStringBuilder() in this scenario.

Based on the docs: appendSuper(super.toString())

Is equivalent to super.ToString() + currentString.ToString() (regardless of if thats correct syntax or not)

and

append(super.toString())

Is equivalent to currentSTring.ToString() + super.ToString()

Woot4Moo
I think the ToStringBuilder is an object that uses reflection to properly create a toString method for an object.
I82Much
Interesting. Good to know.
Woot4Moo