Java doesn’t support pointers; are there any alternatives?
Note that I’m not referring to function pointers, but to pointers!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well, pointers exist in C++ to allow a level of indirection when passing objects around so that an object can be modified or accessed in different areas of code. This is what happens by default in Java, but it approaches it in a different way. In Java, everything you have is a reference. The name you use to refer to an object is a reference to that object. When you call a function, that reference is copied into the function (passed by value). You can think of the variable names in Java as being similar to (or behaving like) pointers in C++.