Reputation: 5518
I'm finding it incredibly difficult to comprehend how different objects should communicate and exchange information.
Coming from the C/C++ world, I'm used to pass objects by reference when I need to give an object to a class/function for processing.
I'm certain that there's a we'll known pattern for achieving clean and maintainable way for object communication. I just need to find out what it is.
EDIT: Example
ObjectThatNeedsProcessing obj;
WizardDialog dialog = new WizardDialog;
dialog.addObjectToBeProcessed(obj);
dialog.show();
//When the dialog is finished obj would be changed.
Best regards
Upvotes: 1
Views: 148
Reputation: 5005
I'm no C++ programmer but in C you pass everything by value (even pointers are passed by value, they just point to something) - and it's the same in Java.
And for the next person who marks this as negative - please explain why so that everyone else understands.
Upvotes: 0
Reputation: 31789
When you pass an object to a method in java, another reference is made to the existing object. So you have 2 references to the same object.
Upvotes: 1