I have a normal Database call that gathers information from my database. i use these informations to create my objects (CallQueue
) these objects are then added to a list and the list is then returned.
Suddenly i discovered that my originally code did not work as intended because i created dublicates and so now i am trying to void that any dublicates are being created! But there is a problem!
I am unable to loop through my list and check wether or not the object is already created!
Here is my code:
while (query.next()) {
if (!queues.isEmpty()) {
/*This gives the Execption->*/
for (CallQueue callQueue : queues) {
if (callQueue.getType().equals(query.getString("KØ"))) {
double decimalTime = query.getDouble("TID");
int hourOfDay = (int)Math.round(24 * decimalTime);
int callAmount = query.getInteger("ANTAL_KALD");
if (hourOfDay > 19) {
hourOfDay = 19;
}
callQueue.addCallsByTime(hourOfDay, callAmount);
} else {
String queueName = query.getString("Kø");
if (!queueName.equalsIgnoreCase("PrivatOverflow")) {
CallQueue cq = new CallQueue(query.getString("KØ"));
double decimalTime = query.getDouble("TID");
int hourOfDay = (int)Math.round(24 * decimalTime);
int callAmount = query.getInteger("ANTAL_KALD");
if (hourOfDay > 19) {
hourOfDay = 19;
}
cq.addCallsByTime(hourOfDay, callAmount);
queues.add(cq);
}
}
}
} else {
String queueName = query.getString("Kø");
if (!queueName.equalsIgnoreCase("PrivatOverflow")) {
CallQueue cq = new CallQueue(query.getString("KØ"));
double decimalTime = query.getDouble("TID");
int hourOfDay = (int)Math.round(24 * decimalTime);
int callAmount = query.getInteger("ANTAL_KALD");
if (hourOfDay > 19) {
hourOfDay = 19;
}
cq.addCallsByTime(hourOfDay, callAmount);
queues.add(cq);
}
}
}
for (CallQueue callQueue : queues) {
System.out.println(callQueue.getType());
}
query.Close();
return queues;
The execption i get from this is:
Caused by: java.util.ConcurrentModificationException
ive tried to look up the execption at ConcurrentModificationException
Can anyone help me fix this problem?