C++ supports pointers whereas Java does not. But when many programmers questioned how you can work without pointers, the promoters began saying “Restricted pointers.” So we can say Java supports Restricted pointers?
C++ supports pointers whereas Java does not. But when many programmers questioned how you
Share
The terminology is quite fuzzy here.
Java supports what it calls “references”. References act a lot like pointers in C/C++-like languages. They don’t act the same way “references” work in those languages.
The major differences between a pointer in C and a reference in Java are:
For some uses of pointers this has no real effect (for example linked lists work pretty much the same in both languages), for others the difference is quite major (arrays in C are just fancy pointer arithmetic, in Java they work quite differently).
So in a way Java references could be called “restricted pointers”.
Wikipedia defines a pointer as
Emphasis mine. According to this strict definition, Java doesn’t have pointers.
The more general reference is the superclass of pointers, but also contrains more abstract things like file handles or even URLs.