Can you get the previous value of a variable in Java?

Posted by The Special One on Stack Overflow See other posts from Stack Overflow or by The Special One
Published on 2009-03-04T15:08:25Z Indexed on 2010/05/19 8:50 UTC
Read the original article Hit count: 161

Filed under:
|

Say way have a variable (let's say String Str) and the value of Str starts of as " " then as some code is running it is set to "test" then somewhere else in the code it is changed again to say "tester". Now in the program I want to find out what the previous value of Str was. Is this possible in Java?

So I am saying that the variable gets changed twice, and you want to find out what Str was before it got changed for the second time. So in the example above the latest value of Str would be "tester" but I wanted to find out what Str was before this (assuming you had no idea what it was before it was changed to tester) in this case I would want to be able to find out that Str was "test".

Is it at all possible to do this in Java?

© Stack Overflow or respective owner

Related posts about java

Related posts about variables