集册 Java实例教程 从LinkedHashSet中删除指定的元素

从LinkedHashSet中删除指定的元素

欢马劈雪     最近更新时间:2020-01-02 10:19:05

652
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
从LinkedHashSet中移除指定元素
/*来 自 nowjava - 时代Java*/

import java.util.LinkedHashSet;

 

public class Main {

  public static void main(String[] args) {

    LinkedHashSet lhashSet = new LinkedHashSet();

   

    lhashSet.add(new Integer("1"));

    lhashSet.add(new Integer("2"));

    lhashSet.add(new Integer("3"));

   

    System.out.println("LinkedHashSet before removal : " + lhashSet);

   

    boolean blnRemoved = lhashSet.remove(new Integer("2"));

    System.out.println(
展开阅读全文