I´m unable to create HashMap/ArrayList objects. If I try to create a new HashMap, IntelliJ is asking for initialCapacity and LoadFactor, which is supposed to be an int/float. If I declare a HashMap with String/String K/V the code is underlined, IntelliJ can recognise it as a new object, but the put method is missing or not recognised. I´m not sure what could cause it, I have reinstalled the JDK and IntelliJ but the problem remains. I have also opened some older rojects where anything written previously works fine, however new lines produce the same issue. Here is snippet of my code just as an example:
import java.util.*;
public class TestClass {
HashMap<String, String> testMap = new HashMap<>("firstString", "secondString");
testMap.put("first", "second");
}
Some data that might be relevant: -java version "17.0.5" 2022-10-18 LTS -IntelliJ community IDEA 2022.2.3
Thanks a lot for the help in advance, and sorry for the bad formatting, I´ll make sure to improve it in the future.
There is no constructor of
HashMap
that receives a sequence of keys and values.Either use:
or
(although the latter is immutable)