提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
获取哈希集的大小
/* from 时代Java - N o w J a v a . c o m*/ import java.util.HashSet; public class Main { public static void main(String[] args) { HashSet hSet = new HashSet(); System.out.println("Size of HashSet : " + hSet.size()); //add elements to HashSet object hSet.add(new Integer("1")); hSet.add(new Integer("2")); hSet.add(new Integer("3")); System.out.println("Size of HashSet after addition : " + hSet.size()); //remove one element from HashSet using remove method hSet.remove(new