Reputation: 4483
I have a static Arraylist and calling a adapter with these values. Does java recreate this variables in each scope ?
Example
In FirstActivity.java
static List<Cars> cars;
new ContentAdapter(this,cars);
In ContentAdapter.java
static List<Cars> cars;
public ContentAdapter(FragmentActivity c,List<cars> ca) {
mContext = c;
cars = ca;
}
Does java re-create cars Arraylist ? And how can i avoid that ?
Upvotes: 0
Views: 59
Reputation: 7846
In the code that you've provided, you have an object reference ca
which gets assigned to your cars
variable. That's not recreating the object, it's just making the object accessible via a new variable. So I don't think you need to worry about the object being recreated.
Upvotes: 1