Originally posted by fundupuneet vyas:
as we know object references are implemented via pointers,then why we don't have access of pointers in java...
There are many reasons, but the two big ones are probably....
Security. You can't implementment the security model needed for applets. Or even needed in a shared model used in application servers, if an application can do pointer arithmetic to access portions of memory that they are not allowed to touch.
Garbage Collection. It would be impossible to detect whether something has been dereferenced, if the program can convert a pointer to an integer, so that it can calculate the reference later.
Have said that... as you already mentioned ... References are like pointers -- you just can't do pointer arithmetic with them.
Henry
[ October 05, 2007: Message edited by: Henry Wong ]