-6

For someone coming from C++ background, what is the best way to understand how Java operates without pointers?

Ankit Sahay
  • 41
  • 1
  • 8
  • Why do you think the absence of pointers needs to be compensated for? – President James K. Polk Nov 11 '16 at 21:00
  • Java has now way to acess memory directly _by design_ and the absence of pointers is considered a _feature_. You don't have to think about deleting stuff after using it, you can't (normally) create a segfault or forget to terminate a string etc etc... – Gumbo Nov 11 '16 at 21:22
  • 1
    *References* are essentially pointers. The only thing java disallows is free manipulation of their value; by restricting the possible operations to dereferencing and assignment. – Durandal Nov 11 '16 at 21:27
  • @JamesKPolk in order to access memory. Am I wrong in expecting so? – Ankit Sahay Nov 11 '16 at 21:29
  • You haven't defined what you mean by "access memory." Java can manipulate objects on its heap as much as you like. – Louis Wasserman Nov 11 '16 at 22:29

1 Answers1

2

Java is a garbage collected language. There are pointers, but they are managed for you by a memory manager. See various answers on SO, such as What is the garbage collector in Java?

Community
  • 1
  • 1
Lunaweaver
  • 206
  • 1
  • 9