Dose Java has pointer ?
No, Java does not have
pointers. This was an intentional decision by the creators of Java, because
most people would agree that having pointers creates a lot of potential for
bugs in the code – pointers can be quite confusing, especially to new programmers.
Because arrays and strings are provided as class types in Java, there is no
need for pointers to those constructs. By not allowing pointers, Java provides
effectively provides another level of abstraction to the programmer.Java has references, but not pointers.All values of non primitive type / reference type are always stored as pointers in the memory. Here are some of the differences between references in Java and pointers in C++:
1. References store an address. That address is the address in memory of the object. So, when a class is declared like so:
"PersonClass y = new PersonClass();"
the "y" variable actually stores an address in memory. If you were to look at that address in memory you would see the details of the PersonClass object. Pointers in C++, however, point directly to the object.
"PersonClass y = new PersonClass();"
the "y" variable actually stores an address in memory. If you were to look at that address in memory you would see the details of the PersonClass object. Pointers in C++, however, point directly to the object.
2. You can not perform arithmetic operations on
references. So, adding 1 to a pointer is not possible, but is possible in C++.
Thanks for sharing this- good stuff! Keep up the great work, we look forward to reading more from you in the future!
ReplyDeleteRegards,
Java Online Training | Java Online Training in India | Java Online Training India | Java Online Training in Hyderabad | Java Online Training Hyderabad | Java Training in Hyderabad | Java Training in India | Java Training Institutes in India | Java Training Institutes in Hyderabad | Java Course in Hyderabad | Java Training | Learn Java Online | Online Java Training | Best Java online Training Institutes in Hyderabad | Best Java Training Institutes in Hyderabad | Best Institutes for Java | Java Institutes in Hyderabad | Best Institutes for Java in Hyderabad | Learn Java | Java Training Institutes in Hyderabad | Java Certification | Java Certification Training | Java Certification Training in Hyderabad | Java Certification Training in India