First of all, why is the map a HashMap<String, ArrayList<String>>
and not a HashMap<String, List<String>>
? Is there some reason why the value must be a specific implementation of interface List
(ArrayList
in this case)?
Arrays.asList
does not return a java.util.ArrayList
, so you can't assign the return value of Arrays.asList
to a variable of type ArrayList
.
Instead of:
allWords = Arrays.asList(strTemp.toLowerCase().split("\\s+"));
Try this:
allWords.addAll(Arrays.asList(strTemp.toLowerCase().split("\\s+")));