【发布时间】:2011-04-18 01:07:19
【问题描述】:
我的页面获得了一个 ArrayList
我不知道唯一类型或文档的数量。
我想将此 ArrayList 排序为 HashMap
一些伪代码喜欢
for (int i = 0; i < documents.size(); i++)
{
if there is an array for documents[i].type
add to this array
else create a new array for this type
add document[i].type and the array of documents with matching type to the hashmap
}
我知道这是错误的方法,显然行不通。我愿意接受任何建议。
谢谢
【问题讨论】:
标签: java sorting arraylist hashmap