Originally posted by Jake Miller:
...How would I have y reference x, as in if I changed x it would also change y? (Like in excel when you reference another cell and change that cell...)
That's a good question.
You cannot do this with Java primitive types, because the value itself is simply copied to the new variable. But if you want y to change whenever x changes, then maybe you don't need y at all. Just use x.
A more elaborate approach would be to replace y with a method that "gets" the current value of x when needed. This might be appropriate if x is an instance variable of some other object.