I have a HashMap<String, ArrayList<String>>. I am trying to convert it to a HashMap<String, String[]>.
HashMap<String, ArrayList<String>> arrayListMap = new HashMap<>();
HashMap<String, String[]> arrayMap = new HashMap<>();
for (Map.Entry<String, ArrayList<String>> entry : arrayListMap.entrySet()) {
arrayMap.put(entry.getKey(), entry.getValue().toArray());
}
However, for entry.getValue().toArray(), my IDE is giving me the error:
Wrong 2nd argument type. Found: 'java.lang.Object[], required 'java.lang.String[]'.
I don't know why, because the arrayListMap specifies that I will be working with Strings.
Why is this not working, and how can I fix it?