简体   繁体   中英

will an instance variable of other class be destroyed when activity is destroyed?

I am new to Java and Android.

Please don't hesitate to explain if my question is silly..

I have a reference to another class

someclass x = new someclass()

in activity (MainActivity.java) class and that class(someclass) has one static variable.

Is that reference variable(instance variable of class) destroyed when the activity is destroyed?

I'm asking this question because the class holds some static variables....

static variables exist whether objects of that class exist or not. So the value will be there even if MainActivity 's onDestroy() gets called. If you have 100 other activities, they will also have access to the static variable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM