了解即可,用得不多。
类 java.util.Dictionary
Dictionary 类是抽象类,存储【键/值】】对,和Map类相似,但是已经过时,实际开发中,可以通过实现Map接口来获取键/值的存储功能
Dictionary的抽象方法如下所示:
参考:http://blog.csdn.net/gengxiaoming7/article/details/47420477
下面是一个实现Dictionary的类:
import java.util.*; public class DictionaryTest extends Dictionary{ private Vector keys=new Vector(); private Vector values=new Vector(); public int size(){ return keys.size(); } public boolean isEmpty(){ return keys.isEmpty(); } public Object put(Object key,Object value){ keys.addElement(key); values.addElement(value); return key; } public Object get(Object key){ int index=keys.indexOf(key); if(index==-1) return null; else return values.elementAt(index); } public Object remove(Object key){ int index=keys.indexOf(key); if(index==-1) return null; keys.removeElementAt(index); Object value=values.elementAt(index); values.removeElementAt(index); return value; } public Enumeration keys(){ return keys.elements(); } public Enumeration elements(){ return values.elements(); } public static void main(String[] args) { // TODO Auto-generated method stub DictionaryTest sub=new DictionaryTest(); for(char c='a';c<'z';c++){ sub.put(String.valueOf(c), String.valueOf(c).toUpperCase()); } System.out.println(sub.get(String.valueOf('d'))); } }