michal.niko...@elanor.cz napsal(a):
> Diky moc za uvedeny priklad. Vystupem u me je (Eclipse):
> 
> 1580473: java.lang.obj...@42e816 - java.lang.obj...@42e816
> 1580473: (false) 4384790 - 4384790
> 
> pricemz je pro me prekvapujici ten (false) ve vypisu. Vzdy jsem si myslel 
> ze porovnani objektu obj == clash je prave porovnani pres identityHashCode 
> (coz jsem prave mylne pokladal za adresu instance na heapu). Njn, diky za 
> informace a jdu to udelat pres tu WeakReference a porovnavat budu pres 
> "==".

Javadoc k Object.hashCode() povídá:

 As much as is reasonably practical, the hashCode method defined by class 
Object does
 return distinct integers for distinct objects.
 (This is typically implemented by converting the internal address of the 
object into an integer,
 but this implementation technique is not required by the JavaTM programming 
language.)

Tj. není to adresa instance na heapu, ale integer vyrobený z adresy instance na 
heapu.
Adresa může mít větší bitový rozsah než integer, takže dvě různé adresy
mohou vyprodukovat stejný integer.

Makub
-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Supercomputing Center Brno             Martin Kuba
Institute of Computer Science    email: ma...@ics.muni.cz
Masaryk University             http://www.ics.muni.cz/~makub/
Botanicka 68a, 60200 Brno, CZ     mobil: +420-603-533775
--------------------------------------------------------------

Odpovedet emailem