+ 2
How to find adress of a object in java or its reference in memory can it be done???
Creating a object obviously by using new it will go to heap but it is been referenced from main function loaded in stack using the object name and hence how will we find the address of referenced object
4 odpowiedzi
+ 2
you can find the address of reference by using
sun.misc.Unsafe class but it is very unsafe
+ 2
well Java wanted to make sure that accessing an address in memory is hard . as Vijay said you need an object of Unsafe class ....... looks like it's constructor is private ...... so good luck instantiating it. (I'm not saying it's impossible thou .... I just couldn't get it done)
if you Google it you'll find something for sure
+ 1
does hashcode returns the exact memory address or it is having its own JVM related concept
0
I'm not sure but I don't think so since hashcode changes for every execution