Java.util.Dictionary.isEmpty() 方法


Java.util.Dictionary.isEmpty() 方法

package com.codingdict;

import java.util.*;

public class DictionaryDemo {
   public static void main(String[] args) {

      // create a new hashtable
      Dictionary d = new Hashtable();

      // add elements in the hashtable
      d.put("1", "Chocolate");
      d.put("2", "Cocoa");
      d.put("5", "Coffee");

      // return true if this dictionary maps no keys to value.
      boolean b = d.isEmpty();
      System.out.println("Dictionary is empty:" + b);
   }
}