java.util.ConcurrentModificationException: "This exception may be thrown by methods that have detected concurrent modification of an object when such modification is not permissible."
Any idea why my set method gives this exception?
private ArrayList<Double> voltagesList = new ArrayList<Double>();
private ArrayList<String> devicesList = new ArrayList<String>();
public void setVoltage(String device, double voltage) {
for(String d: devicesList){
if(d.equals(device)){
voltagesList.set(devicesList.indexOf(device), voltage);
}
else{
voltagesList.add(voltage);
devicesList.add(device);
}
}
}