目录

abstract V get(Object key)

描述 (Description)

java.util.Dictionary.get(Object key)方法返回字典中给出的键上的值。

声明 (Declaration)

以下是java.util.Dictionary.get()方法的声明

public abstract V get(Object key)

参数 (Parameters)

key - 这本词典中的一把钥匙。 如果key未映射到任何值,则可以为null。

返回值 (Return Value)

此方法返回键在此字典中映射到的值。

异常 (Exception)

NA

例子 (Example)

以下示例显示了java.util.Dictionary.get()方法的用法。

package com.iowiki;
import java.util.*;
public class DictionaryDemo {
   public static void main(String[] args) {
      // create a new hashtable
      Dictionary dict = new Hashtable();
      // add elements in the hashtable
      dict.put("1", "Chocolate");
      dict.put("2", "Cocoa");
      dict.put("6", "Coffee");
      // returns the elements associated with the key
      System.out.println(dict.get("6"));
   }
}

让我们编译并运行上面的程序,这将产生以下结果 -

Coffee
↑回到顶部↑
WIKI教程 @2018