well.. back to c and c++,we can used pointer to access the memory address of data.

But how to access memory address in java?

i do search at daniweb and found this post..


but it not happen with my program.This is my program.

Node x = new Node(new Integer(4)), y = new Node(new Integer(7)) ;
//How to access the memory address of x and y?

i did try the method explain in the post by crbsathy.. which to implement .toString() to it.but it's only gonna display the value of the data.

Thanx in advance.

BTW, objects toString method prints the hashCode of the object in hex representation. That is not, necessarily, a memory address in the first place.

So, in short, you can't access the "memory location". The physical memory location has, for the Java programmer, no relevance. You do not need it, and should not even attempt to get it.

IOW why do you think you need it? There is probably a much better, and easier, way to do whatever it is you want to do.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.