For someone coming from C++ background, what is the best way to understand how Java operates without pointers?
-
Why do you think the absence of pointers needs to be compensated for?President James K. Polk– President James K. Polk2016-11-11 21:00:43 +00:00Commented Nov 11, 2016 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– Gumbo2016-11-11 21:22:42 +00:00Commented Nov 11, 2016 at 21:22
-
1References are essentially pointers. The only thing java disallows is free manipulation of their value; by restricting the possible operations to dereferencing and assignment.Durandal– Durandal2016-11-11 21:27:31 +00:00Commented Nov 11, 2016 at 21:27
-
@JamesKPolk in order to access memory. Am I wrong in expecting so?Ankit Sahay– Ankit Sahay2016-11-11 21:29:20 +00:00Commented Nov 11, 2016 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– Louis Wasserman2016-11-11 22:29:59 +00:00Commented Nov 11, 2016 at 22:29
Add a comment
|
1 Answer
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?