This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Cattle Drive and the fly likes Stuck with stubborn return values - please give hints Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "Stuck with stubborn return values - please give hints" Watch "Stuck with stubborn return values - please give hints" New topic
Author

Stuck with stubborn return values - please give hints

juliane gross
Ranch Hand

Joined: May 30, 2002
Posts: 161
My main method calls a method no1, which is calling a method no2 three times in a row.
Now I wish that method2 would return either value x or value y
(depending on some if-else results) to method1, so that method1 continues calling
method no2 with that newly changed value.
But method no1 stubbornly calculates in all three calls with the value it got from the
main method no matter what the return value was from method no2.
My question: how can I "convince" method no1 to accept the return value of method no2
and forget about the given value in the main method?
thank you for your patience of answering this (probably very green) question..

juliane
Ronald Schindler
Ranch Hand

Joined: Jul 11, 2000
Posts: 50
Hey Juliane,
without seeing code its a little hard to make a definite determination. But it sounds as if you have the variable being set with the first method each time it is called. You might want to try looking at the scope of the variable within the first method.
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9044
    
  10
Are you saving the value that was returned? Did you assign it to an identifier?


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
juliane gross
Ranch Hand

Joined: May 30, 2002
Posts: 161
thank you for bothering, Ronald and Marilyn!
I had my program running 2 minutes after your
hints, thank you!! (and even smaller )
Juliane
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Stuck with stubborn return values - please give hints