H
H
Horoko2015-05-27 17:37:31
Java
Horoko, 2015-05-27 17:37:31

How long is the value stored in the variable?

Subject. For example, when a button is pressed, I assign the string value obtained from the EditText to a string variable, and then I need to work with the same value from another activity. How long is the value stored in this variable? Before exiting the application?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Gusev, 2015-05-27
@Horoko

In general, while the variable exists, if it is not overwritten / deleted, then it will be stored in memory exactly as long as the program is running, and with it the value.
"Before exiting the application?" - Yes, after the exit, for good, everything that the program has created in memory is released. If you want to save values, then write them to files.

V
Vitaly Filinkov, 2015-05-27
@vitfil

Perhaps my statement "5 seconds" has the right to life, as a special case. The value in the variable will be stored, at least until you assign something else to the variable, and at most, as long as the object exists. And we haven't got into the wilds of the scope of variables yet...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question