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
But, what Java does have is references, which are different from pointers. Here are some of the differences between references in Java and pointers in C++:
Comments
Post a Comment