In my code I have this line:
private static ArrayList<Item> items = new ArrayList<Item>();
and then I defined my setter function like this
public void setItems(ArrayList<Item> items) {
this.items = items;
}
And NetBeans complains Accessing static field items, replace with class reference?
If I would replace this call with class reference like MyClass.items = items; it wouldn’t be propagated into current object, isn’t it?
A static variable is never “propagated” into the “current” object.
It is static, bound to the class. It lives even without an instance of the class, so there is no need to “propagate” it.
Btw: I would change the name of the method parameter, it is confusing to have the same name twice inside a method (and you wouldn’t need the this if the parameter wasn’t named like the static variable: