Replace this lambda with a method reference [duplicate]
up vote
7
down vote
favorite
This question already has an answer here:
How to fix ambiguous type on method reference (toString of an Integer)?
3 answers
I have the following code. Sonar is complaining replace this lambda with a method reference. Stream.iterate(0, i -> i + 1).limit(100).map(i -> Integer.toString(i)); If I replace it with it code below, it does not compile with compilation error: Type mismatch: cannot convert from Stream<Object> to <unknown> . Stream.iterate(0, i -> i + 1).limit(100).map(Integer::toString); How is Integer::toString converting Stream<Object> to <unknown> ?
java java-8 sonarqube java-stream