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.

6 Years
Discussion Span
Last Post by masijade

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.