I've been reading about this for a while now and I can't figure it out. Consider these classes, both in their own file.
public class World {
private List<Entity> entities = new ArrayList<>();
public List<Entity> getEntities() {
return entities;
}
public void setEntities(List<Entity> entities) {
this.entities = entities;
}
}
public Class Entity {
public Entity() {
List<Entity> modifiedList = World.getEntities().add(this); // 1
World.setEntities(modifiedList);
}
}
There's a type mismatch: I cannot convert from boolean to List (1) How would I solve this? How could you possibly convert a boolean to a List? Also, the concept static confuses me. If anyone can direct me to some light, and accessible read about static vs non-static, please post it in the comments!