GeeksforGeeks » Java specific Questions
References in Java and C++
(2 posts)-
What are the differences between references in C++ and Java?
-
Java references are much stronger than C++ references. In C++, a reference has to be initialized with declaration and can refer to only one object. It cannot be changed to refer to any other object.
In Java, a reference can have null value, it can be changed to refer to as many object as you want. References being more strong in Java is one of the reasons Java programs don't need pointers. For example, data structures like Linked List and Trees can be implemented using Java references, but not C++ references, in C++, you need pointers to implement them.
Reply
You must log in to post.