集册 Java实例教程 获取哈希表的大小

获取哈希表的大小

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

507
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
获取哈希表的大小

 

import java.util.Hashtable;

 
 /**
  from
 * 时 代 J a v a - N o w J a v a . c o m 
 **/

public class Main {

 

  public static void main(String[] args) {

    Hashtable ht = new Hashtable();

    System.out.println("Size of Hashtable : " + ht.size());

   

    //add key value pairs to Hashtable using put method

    ht.put("1","One");

    ht.put("2","Two");

    ht.put("3","Three");

    System.out.println("Size of Hashtable after addition : " + ht.size());

   

    Object obj = ht.remove(
展开阅读全文