这个Java的list运行的时候为什么会报错?
PHP中文网
PHP中文网 2017-04-18 10:22:29
0
2
401
for (car_gps car_gps : locList) {
                        if(car_gps.getGps_lat().contains("E")||car_gps.getGps_lng().contains("E")){  //排除异常坐标
                              locList.remove(car_gps);
                            
                          }
                    }
PHP中文网
PHP中文网

认证高级PHP讲师

reply all(2)
Ty80

When foreach loops a list, you cannot remove elements of the looped list in the loop body. You can use the iterator method, or record the index of the element to be deleted first, and then delete the elements with corresponding indexes after the for loop ends.

Ty80

Brother, how do we know what is in locList? What is the car_gps object? At least give me an error message

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template