Reputation: 151
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....
Upvotes: 0
Views: 1206
Reputation: 24998
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.
Upvotes: 1