package org.javacore.collection.list; /*
 * Copyright [2015] [Jeff Lee]
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;

/**
 * @author BYSocket
 * @since 2016-01-06 20:11:00
 *  打印list 全部元素，并找到其中元素aaa删除。要求：所有元素都遍历完
 *          ListIterator 的使用
 */
public class ListT0 {
    public static void main(String[] args) {
        List<String> list =new ArrayList<>();
        list.add("1");
        list.add("2");
        list.add("3");
        list.add("4");
        list.add("aaa");
        list.add("6");
        list.add("7");

        ListIterator listIterator = list.listIterator();
        while (listIterator.hasNext()) {
            Object o = listIterator.next();
            System.out.println(o);
            if (o.equals("aaa")) {
                listIterator.remove();
            }
        }
    }

}

@@ -835,16 +835,95 @@
 tor %E7%9A%84%E4%BD%BF%E7%94%A8%0A
+ *  list%E9%82%A3%E4%B8%AAremove%E5%9B%9E%E6%8A%9B%E5%BC%82%E5%B8%B8%E6%98%AF%E5%9B%A0%E4%B8%BA%E5%BF%AB%E9%80%9F%E5%A4%B1%E8%B4%A5%E7%9A%84%E6%9C%BA%E5%88%B6%EF%BC%8C%0A *  %E4%BB%96%E5%86%85%E7%BD%AE%E4%BA%86%E4%B8%80%E4%B8%AAmodifyCount%E7%9A%84%E5%8F%98%E9%87%8F%E8%AE%B0%E5%BD%95list%E7%9A%84%E9%95%BF%E5%BA%A6%E5%8F%98%E5%8C%96%EF%BC%8C%E7%94%A8Iter%E5%8F%AF%E4%BB%A5%E5%88%A0%E9%99%A4%E6%8E%89%0A
  */%0Apubl

修正：ListIterator 的使用