Dedian |
|
|||
-- 關注搜索引擎的開發 |
日歷
統計
導航常用鏈接留言簿(8)隨筆分類(45)
隨筆檔案(82)
文章檔案(2)Java Spaces搜索積分與排名
最新評論
閱讀排行榜評論排行榜 |
Unlike collection types such as Vector or List, Map (HashTable or
HashMap) accesses a value by a key. If we want to retrieve all the
values that have been put in a Map, one of simple ways to do that is
employing a Collection or plus an Iterator, here is the sample code
(just retrieve vaules, skip keys), assuming there is a variable:
HashMap<String, <ComplexDataType>> links
Collection c = links.value(); Vector<ComplexDataType> v = new Vector<ComplexDataType>(c); for(int i = 0; i< v.size(); i++) { ??? ComplexDataType tempData = (ComplexDataType)v.get(i); ??? dosomethingwith(tempData); } P.S. Map provides three views of map: keySet, entrySet and values collection, we can use any of them .
|
![]() |
|
Copyright © Dedian | Powered by: 博客園 模板提供:滬江博客 |