What am I missing? Why do I have to use Object::toString
below and not Integer::toString
? Does it have anything to do with type erasure with generics?
Arrays.asList(1,2,3).stream().map(Integer::toString).forEach(System.out::println); //Won't compile
Arrays.asList(1,2,3).stream().map(Object::toString).forEach(System.out::println); //Compiles and runs fine