This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Memory Address Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Memory Address" Watch "Memory Address" New topic

Memory Address

Shrinivas Mujumdar
Ranch Hand

Joined: Aug 27, 2004
Posts: 328
Hello All,
Can i get a memory address of an object in Java?, One way is to use hashCode() method , but it may not give a memory address always (like e.g. String class has overriden hashode() method). is there any other way to get memory Address?
fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11150

A question for you...

Why do you WANT the memory address? What are you planning on doing with it?

In java, memory addresses aren't very useful - there is no pointer arithmatic like in C/C++.

If you tell us your goal, maybe we can help you find a better way...

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Shrinivas Mujumdar
Ranch Hand

Joined: Aug 27, 2004
Posts: 328
Nothing great with Memory Address but need to know about the same just out of curosity..

I agree. Here's the link:
subject: Memory Address
Similar Threads
Address vs reference
Output of a simple code
Pass by value or reference?
Probably it may be really silly question for others but not for me.
Method Calling