0
Pointer in Java
why does java omit the pointer?
3 Respostas
+ 1
Java does have pointers. Any time you create an object in Java, you're actually creating a pointer to the object; this pointer could then be set to a different object or to null, and the original object will still exist (pending garbage collection).
What you can't do in Java is pointer arithmetic. You can't dereference a specific memory address or increment a pointer.
Unlike C/C++ where pointers are variables which explicitly store memory addresses, and which can be modified arithmetically to point to any arbitrary address java doesn't have that capability.
It enhances security we can say.
+ 7
Java doesn't give the programmer direct access to memory, therefore no pointers no malloc no free no realloc etc. This is done for safety reasons, it protects the programmer from tampering with things (in Java's mind at least) they shouldn't.