#How to fix this basic problem
6 messages · Page 1 of 1 (latest)
You might have heard that Java is pass-by-value. You can't reassign a variable you passed as parameter, or more exactly doing so has no effect on what was passed.
Mostly because when you define a method with a parameter:
public static void twice(int a) {
a = a + a;
return a;
}
then what do you think happens to 3 when you call twice(3) ?
In theory you could pass as parameter an array of three ints. As arrays are objects, they're always pointed to, so the array is not copied, only the reference to it is copied.
You can put new values inside the array, you just can't reassign the array itself.
so technically it will return x1, x2,x3 and not the function i created x1 = x2+x3
what will what? You're responding to a specific line of mine but that looks out of context