KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm a complete Java noob. I know that Java treats all parameters as pass by value and there are several other threads where people explain this. For example, in C++ I can do: void makeAThree(int &n) { n = 3; } int main() { int myInt = 4; makeAThree(myInt); cout << myInt; } Which will output 3. I know that in Java, all parameters are passed by value and thus you can not manipulate the parameter passed in. Is there a standard way to simulate pass by reference in Java? Is there no way to call a function that manipulates a variable passed in? It's tough for me to wrap my head around the idea of there being no way to do this.
Tags (comma-separated)
Save Edits
Cancel