I skipped a ConcurrentModificationException when iterating over a list: List<Attribute> attributes
This list contains objects of type Attribute , which will be used to create views AttributeView :
The method I use to create the views:
public void createAttributeViews(List<Attribute> attributes) {
if (attributes.size() != -1) { //La lista debe contener elementos
Iterator<Attribute> iter = attributes.iterator();
while (iter.hasNext()) {
Attribute attribute = iter.next();
AttributeView view = new AttributeView(attribute);
mainPanel.add(view.getMainPanel()); //añade la vista al panel principal
}
}
}
I get the error in the line: Attribute attribute = iter.next();
all call iter.next()
The list that passed as parameter in the public void createAttributeViews(List<Attribute> attributes)
method inizializzo like this:
protected void init(User user) {
List<Attribute> userAttributes = new ArrayList<>();
userAttributes.addAll(userAttributeService.getUserAttributesById(user.getId()));
createAttributeViews(userAttributes);
}
Why is the error?