package com.niit.www;
public class Record {
private int id;
private String name;
private String telephone;
private String remark;
public Record(int id, String name, String telephone, String remark) {
super();
this.id = id;
this.name = name;
this.telephone = telephone;
this.remark = remark;
}
public Record()
{}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getTelephone() {
return telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
}
Hashtable <String,Record>hashTable=new Hashtable<String,Record>();
Record re=new Record(1001,"jack","15165800700","chinese");
Record re1=new Record(1002,"mike","15168421155","American");
Record re2=new Record(1003,"rose","0154-8556","European");
hashTable.put("1", re);
hashTable.put("2", re1);
hashTable.put("3", re2);
}
我想用一个for循环遍历 hashTable的 values值
用了Enunmeration Entry KeySet都搞不定。。
谁指点下小弟啊。。。。
Set<String> keys=hashTable.KeySet();
while(keys.hasNext){
Record r = hashtable.get(keys.next());
}
建议你是使用这个类型吧 IDictionary
谁还让用HashTable这种过时的容器???
用HashMap和TreeMap还不够用吗?
知道HashTable会带来哪些问题吗?
{
//注意HastTable内存储的默认类型是object,需要进行转换才可以输出
Record rd= de.Value as Record;
}