集册 Java实例教程 获取Java LinkedHashSet的大小

获取Java LinkedHashSet的大小

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

440
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
获取Java LinkedHashSet的大小
/**时 代      J a v a   公   众 号 - nowjava.com**/


import java.util.LinkedHashSet;

 

public class Main {

 

  public static void main(String[] args) {

    LinkedHashSet lhashSet = new LinkedHashSet();

    System.out.println("Size of LinkedHashSet : " + lhashSet.size());

 

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

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

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

 //时代Java公众号 - N o w J a  v a . c o m

    System.out.println("Size of LinkedHashSet after addition : " + lhashSet.size());

 

    //remove one element from LinkedHashSet using remove method

    lhashSet.remove(
展开阅读全文