aspose file tools*
The moose likes Java in General and the fly likes Function Call Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Function Call Problem" Watch "Function Call Problem" New topic
Author

Function Call Problem

John Stevens
Greenhorn

Joined: Oct 24, 2003
Posts: 5
I have various function calls in a program:
//FUNCTION CALLS
enterDiagonal(matrix, sizeIn);
enterBelowDiagonal(matrix);
enterAboveDiagonal(matrix);
PrintTri(matrix, sizeIn);
int [] oneD = storeTo1D(matrix, sizeIn);
int [] Vectwo = setUpVector2(sizeIn);
int [] sumarr = AddOrSub(sizeIn, oneD, Vectwo);
storeTo1D(matrix, sizeIn);
setUpVector2(sizeIn);
AddOrSub(sizeIn, oneD, Vectwo);
displayarray(oneD, Vectwo, sumarr);
The int[] declaration in the middle indicate the use of local function variables in other functions.
The problem I am having is one the function 'AddOrSub(sizeIn, oneD, Vectwo);' is finished, it seems to go all the way back to 'storeTo1D(matrix, sizeIn);'.
I don't understand why its doing this but Iam pretty sure its those int[] reference declarations that are causing this. I've tried switching them around bu no luck.
Can anyone point me in the right direction?
Thanks.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8996
    
    9

Originally posted by John Stevens:

The int[] declaration in the middle indicate the use of local function variables in other functions.

No it doesn't. It receives the return value of the method call. Very Different Things. I refer you back to the scope article I linked in you previous question.


The problem I am having is one the function 'AddOrSub(sizeIn, oneD, Vectwo);' is finished, it seems to go all the way back to 'storeTo1D(matrix, sizeIn);'.
Thanks.

I don't quite understand this statement, but I think you believe you have declared a link to local variables in other functions by declaring variables with similar names in your main method. Not the case.
I can't figure out why you are calling these methods twice, once using the return values, once not.

What you are doing is calling AddOrSub twice on the same instances of oneD and Vectwo. The second calls to store and setUp don't change those values in this method. Study the scope document. That's what your problem is.


[How To Ask Questions On JavaRanch]
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8996
    
    9

Hmm. Can't edit. Here's your previous submission
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Function Call Problem