When I acces to list of list with this function,It make ConcurrentModificationException in second for loop but i don't understand why this Exception is triggered .
public static List<List<Dico>> weight_term(List<List<Dico>> sublists ,List<String> sinificativ )
{
List<List<Dico>> matrix_node_term = new ArrayList<>();
List<Dico> list_node = new ArrayList<>();// a new list for node
for (List<Dico> sublist : sublists) // to get each sublist List<Dico>
{
for (Dico dico : sublist) // get each Dico in the sublist -->ConcurrentModificationException
{
String term =dico.getTerm();
int id = dico.getDocId();
if(sinificativ.contains(term)) // if this term exist in sinificativ erm list
{
list_node.add(dico); // it add to list_node
}
else
{
list_node.add(new Dico(id,term,0.0)); // it add to list_node with null weigth
}
}
matrix_node_term.add(list_node); // add each list to list of list
}
return matrix_node_term;
}
The dico class is used to store term,id of document and the weight of this term in that document :
public class Dico implements Comparable
{
private final String m_term;
private double m_weight;
private final int m_Id_doc;
public Dico(int Id_Doc,String Term,double tf_ief )
{
this.m_Id_doc = Id_Doc;
this.m_term = Term;
this.m_weight = tf_ief;
}
}
This Exception is triggered without any modification in the sutucte of list or its elements .
>` it's creted by my own function `List
– tommy Apr 15 '15 at 10:08> split_dico(List list)` i split a list of dico in multiple list by id of document were term is stored .
> sublists = new ArrayList<>(change); for (int i = 0; i < change; i++) { sublists.add(list.subList(changes[i], changes[i + 1])); }`
– tommy Apr 15 '15 at 10:41> sublists = new ArrayList<>(change); for (int i = 0; i < change; i++) { sublists.add(new ArrayList(list.subList(changes[i], changes[i + 1]))); }` and the problem should disappear.
– Paul Boddington Apr 15 '15 at 10:42