The get
method of the HashMap
is returning an Object
, but the variable current
is expected to take a ArrayList
:
ArrayList current = new ArrayList();
// ...
current = dictMap.get(dictCode);
For the above code to work, the Object
must be cast to an ArrayList
:
ArrayList current = new ArrayList();
// ...
current = (ArrayList)dictMap.get(dictCode);
However, probably the better way would be to use generic collection objects in the first place:
HashMap<String, ArrayList<Object>> dictMap =
new HashMap<String, ArrayList<Object>>();
// Populate the HashMap.
ArrayList<Object> current = new ArrayList<Object>();
if(dictMap.containsKey(dictCode)) {
current = dictMap.get(dictCode);
}
The above code is assuming that the ArrayList
has a list of Object
s, and that should be changed as necessary.
For more information on generics, The Java Tutorials has a lesson on generics.