作者superlubu (叔叔你人真好)
看板java
标题Re: [问题] hashtable的iterator
时间Tue Jun 17 22:49:37 2008
※ 引述《RUReady2 (Are you ready,too?)》之铭言:
: Hashtable<String,Person> hashtable=people.getSomePerson(id);
: Iterator iterator=hashtable.entrySet().iterator();
: 上面是我写的两行程式
: 我的目的是要把hashtable里面的Person全部读出来
: 再使用Person自己的method
: 可是我用hashtable iterator之後的结果
: 读出来会有exception
: exception是没有Person里面的method
: 所以小弟强烈怀疑读出来的结果不是Person物件
: 请问一下
: 我该怎麽解决这个问题呢?
: 小弟先谢谢大大的解答
1. 你的 "Exception" 是 compilation error 还是 runtime error ?
2. Entry set 的 iterator 出来的是 Entry Object, 请详细阅读 API.
--
劲过吕布的劲过相簿...
http://www.pixnet.net/superlubu
乱七八糟的,不好意思 m(_ _)m
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 203.218.38.49
1F:推 RUReady2:1.compilation error 谢谢大大帮忙 06/17 22:54