zoukankan      html  css  js  c++  java
  • 删除map、list集合元素总结

    @Test
    public void removeElementFromMap()
    {
    Map<Integer, String> test = new HashMap<Integer, String>();
    test.put(1, "a");
    test.put(2, "b");
    test.put(3, "c");
    test.put(4, "d");

    Iterator<Entry<Integer, String>> it = test.entrySet().iterator();

    int key = 0;
    while (it.hasNext())
    {
    key = it.next().getKey();
    if (key == 1)
    {
    it.remove();
    }
    }

    System.out.println(test);
    }

    删除List集合元素:

    @Test
    public void removeElementFromList()
    {
    List<Integer> testList = new ArrayList<Integer>();
    testList.add(1111);
    testList.add(2222);
    testList.add(3333);
    testList.add(4444);

    Iterator<Integer> it = testList.iterator();

    int value = 0;
    while (it.hasNext())
    {
    value = it.next();
    if (value == 1111)
    {
    it.remove();
    }
    }
    }

  • 相关阅读:
    FirstThunk
    FirstThunk
    输入地址表(IAT)
    PE文件讲解
    PE格式详细讲解
    pe结构讲解
    PE格式详细讲解
    输入地址表(IAT)
    pe结构讲解
    zindex可以使用负值
  • 原文地址:https://www.cnblogs.com/doudouxiaoye/p/5669293.html
Copyright © 2011-2022 走看看