Java中Dictionary类的重要性?
甲字典 类是一个 抽象类,它表示一个键/值对和操作类似于图 ,这是一个传统的类中的Java。甲字典 类有两个重要的方法Dictionary.keys()和Dictionary.elements()吨帽子可以通过迭代计数。Dictionary类的其他重要方法是 isEmpty(), get(),remove()和 size()。
语法
public abstract class Dictionary<K,V> extends Object
示例
import java.util.*;
public class DictionaryTest {
public static void main(String[] args) { Dictionary<Integer, String> dic = new Hashtable<Integer, String>(); dic.put(1, "Adithya");
dic.put(2, "Jaidev");
dic.put(3, "Raja");
Enumeration<Integer> key = dic.keys();
while(key.hasMoreElements()) {
System.out.println(key.nextElement());
}
Enumeration<String> element = dic.elements();
while(element.hasMoreElements()) {
System.out.println(element.nextElement());
}
}
}输出结果
3 2 1 Raja Jaidev Adithya
热门推荐
10 朋友新年祝福语大全 简短
11 新年祝福语简短大方兔年
12 搬新家礼物祝福语简短
13 同学见面花束祝福语简短
14 五一假期祝福语幽默简短
15 离职欢送敬酒祝福语简短
16 对学弟的祝福语简短
17 考老师辞职祝福语简短
18 祝福语驱散霉运的话简短