Does anybody know to get the memory addresses of an array indexes?
(like in c)
Does anybody know to get the memory addresses of an array indexes? (like in
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There is no programmer-realizable notion of an “address” in Java. In a language like C or C++, objects’ identities are equated with their address – two objects are the same object if they live in the same memory location. In Java, this notion of identity is decoupled from the object’s address. This allows some optimizations that are not possible in C++. For example, the garbage collector could, in theory, move objects around in memory to avoid fragmentation, so long as it modifies references so they point to the right location. Because memory addresses can’t be accessed directly by the programmer, this operation is permissible. In C++, it wouldn’t work, because the compiler couldn’t tell if a particular bit pattern in memory was some sort of encoded pointer.