- #1
mindauggas
- 127
- 0
Hi,
Wanted to ask you guys how does Java know what specific parameter to take into a method if the method name has to be only - let's call it - "internaly consistent" (meaning the parameter in the head and the body have to be the same).
E.g. if I pass a value to the method:
that uses a for loop:
So here the parameter has to have the same name - internaly consistent.
In the main method this program uses, as an example, the line:
Now information flow can be analysed in terms of "stack frames". Each method get's its own stack frame. But the parameters it accepts from the method-caller are only copies of the parameters (values) not the values themselves. If the names betwean methods have to be consistent only internaly - inside the method - and are relative method-vise how does JAVa realize what parameter I'm referring to?
I hope the question makes sense.
Wanted to ask you guys how does Java know what specific parameter to take into a method if the method name has to be only - let's call it - "internaly consistent" (meaning the parameter in the head and the body have to be the same).
E.g. if I pass a value to the method:
Code:
private int rollDice(int numDice)
Code:
for (int i = 0; i < numDice; i++)
In the main method this program uses, as an example, the line:
Code:
while (true) {
int roll = rollDice(numDice);
Now information flow can be analysed in terms of "stack frames". Each method get's its own stack frame. But the parameters it accepts from the method-caller are only copies of the parameters (values) not the values themselves. If the names betwean methods have to be consistent only internaly - inside the method - and are relative method-vise how does JAVa realize what parameter I'm referring to?
I hope the question makes sense.