You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Peter Donald <do...@apache.org> on 2001/09/13 14:42:41 UTC
Re: toString()
On Thu, 13 Sep 2001 23:35, Paul Hammant wrote:
> Peter,
>
> Re recent diffs....
>
> Generally I am against overriding toString() in classes.
I can't remember where I did it exactly ... where was that again ? ;)
>The only way
> you can get the true object reference for debugging is to do a toString
>
> : "org.apache.Thing@a3b2c3" That is useful when you are hunting
You can also do
System.identityHashcode( myObject )
or even
myObject.getClass().getName() + "@" + System.identityHashcode( myObject )
if you want the exact same format ;)
> problems with multiple instances of a thing or the wrong instance of
> thing. Of course I am talking of traditional debugging -
> System.out.println("blah blah " + m_thing). By overriding toString()
> that is not longer possible. Perhaps another method name for what you
> are trying to do? "String debug()"
Maybe - as I said can't remember where I did it ;)
--
Cheers,
Pete
*---------------------------------------------------------*
| Contrary to popular belief, UNIX is user-friendly. It |
| just happens to be selective on who it makes friendship |
| with. |
| - Richard Cook |
*---------------------------------------------------------*
---------------------------------------------------------------------
To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: avalon-dev-help@jakarta.apache.org
Re: toString()
Posted by Paul Hammant <Pa...@yahoo.com>.
>
>
>
>System.identityHashcode( myObject )
>
Thaks to Peter and Joe, I have a new system function for my arsenal. I
stand corrected.
- Paul
---------------------------------------------------------------------
To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: avalon-dev-help@jakarta.apache.org