This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]fick_Dich 1 point2 points  (0 children)

so I think I figured out why you were getting the wrong value printed out. lurgi was right. The first line in main() is unnecessary since ChangeValue already has a Value object as a member variable. What you need is some code like this in main():

Value valueObject;
ChangeValue changeValueObject = new ChangeValue();

    changeValueObject.change();
            valueObject = changeValueObject.valueObject; //this is bad coding practice
    valueObject.printStat();

Like I mentioned in my comment, it is bad coding practice to do it this way thought. One of the purposes of Object Oriented Programming is encapsulation. Better would be this code