I assume that you are using an IDE (e.g. Eclipse). For example, Eclipse uses its own compiler and does not use the javac command (from the JDK).
So, I can reproduce your problem, but only with Eclipse. Just compiling this code on the command line with javac works just fine.
The problem is very simple: the Eclipse compiler cannot deduce the String type for the arguments to the collect method. Therefore, it simply displays Object (since this is a type that can be safely assumed). And Object does not know the split method.
You can make the compiler learn about String by explicitly declaring the type inside the lambda:
List<String> pairs = new ArrayList<>(); System.out.println(pairs.stream().collect(Collectors.toMap((String x) -> x.split("=")[0], x -> x.split("=")[1])));
... or by explicitly declaring the correct types of the geneirc toMap method:
List<String> pairs = new ArrayList<>(); System.out.println(pairs.stream().collect(Collectors.<String, String, String> toMap(x -> x.split("=")[0], x -> x.split("=")[1])));
source share