Original Post
Howdy yall, I have a little problem. I can't use instance variables and i need to pass by reference. So i can't use primitive data types since they are not passed by reference. I wrapped them up in a wrapper class. I have two Integer types that i send to a method. Once its in the method everything is fine. In the method i sent it to, i send it to another method as Integer (the same wrapper) so there is no change its still a wrapped integer. I do my logic on it and change its value...at the end of that method i check the value. It has value, some number that changes everytime(as it is suppose to do). However right after i check the value, i have a return. Right after i return, the values are reset to 0. But they are wrapped in a class. They should be sending by reference. Take a look at this example that demonstrates the situation.
void main()
{
//
Integer intOne;
Integer intTwo;
firstMethod(intOne, intTwo);
}
void firstMethod(Integer intOne,Integer intTwo)
{
//display stuff
...
getValues(intOne, intTwo);
//right after we return
//display Integers
//they are 0 now :(
}
void getValues(Integer intOne,Integer intTwo)
{
//display the integers...everythings good
//do stuff, change values
//right before we return...display new values...yay the Integers have changed
return;
}
In firstMethod it SHOULD have the changed values because classes are passed by reference, but for some reason, it isnt. The values of the class are changed...it returns, then they are back to 0. There is no code inbetween to change them. The only possible explanation is that it is not passing by reference, but i dont know why. Any help would be greatly appeciated, thank you.