Question: I would like to know what is the difference between these two three pieces of code:

```
underlyingConnectors.values().stream().forEach(connector -> connector.start());

underlyingConnectors.values().forEach(connector -> connector.start());

underlyingConnectors.values().forEach(Connector::start);

```

The second line compiles fine but my Ecplipse IDE complains with "Sonar : Replace this lambda with a method reference".

How do I choose the approriate code to use? Is there a specific use case for each of these?

Answer: 
The first line contains an unnecessary call to `stream()` and the two latter ones are a matter of opinion. If you want to write the shortest and most succinct code, you would use the last one. All of them work in an equivalent way and it's mainly about style.

The `stream()` is unnecessary since `values()` returns a `Collection` which extends `Iterable` which has [forEach(Consumer<? super T> action)](https://www.baeldung.com/foreach-java) already.
Both lines are correct. It is just a warning of sonar lint. The method reference is a simple form of lambda, in case you are returning just a method.