集册 Java实例教程 从LinkedHashSet中删除所有元素

从LinkedHashSet中删除所有元素

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

435
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
从LinkedHashSet中移除所有元素
/**来 自 N o w J a v a . c o m - 时  代  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);

   

    lhashSet.clear();

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