Hi there
I have page gets given an ArrayList<Document> where each document has a property called type.
I don't know the number of unique types or documents.
I want to sort this ArrayList into a HashMap<type, document[]> but am having some trouble getting my head around it.
Some pseudo-code would like like
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
}
I know this is the wrong approach and clearly won't work. I am open to any suggestions.
Thank you