javacollectionssynchronize

Why is my IDEA reporting this error - "Cannot resolve symbol 'synchronizedList'"


public static List<Socket>  socketList = new Collections.synchronizedList(new ArrayList<>());

In the code, Collections.synchronizedList, prompt me Cannot resolve symbol synchronizedList, I don't know what it is. I didn't find this method for Collections in the JDK documentation either (just because I probably couldn't find it, doesn't mean he didn't).

Maybe it's a problem with my IDEA setup, but I can't find it.


Solution

  • You need to remove the new statement from Collections.

    public static List socketList = Collections.synchronizedList(new ArrayList<>());