Aasically I’m trying to add an item from ArrayList a (allApps) to ArrayList b (myApps) but I’m getting an error.
This is what I’m trying:
public ArrayList myApps = new ArrayList();
@Override
public void onCreate(Bundle savedInstanceState) {
...
for(final ResolveInfo app : allApps) {
addApp(app);
}
}
public void addApp(ResolveInfo app) {
ArrayList.add(app); // ERROR: Cannot make a static reference to the non-static method add(Object) from the type ArrayList
}
What does this error mean and how can I get I copy an item from one array to the other?
You need to call add on an instance of ArrayList, not on the class itself, given your description, what you’re looking for is