avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Donald <dona...@apache.org>
Subject Re: toString()
Date Thu, 13 Sep 2001 12:42:41 GMT
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


Mime
View raw message