Mikalai Zaikin wrote:Your code is not a lambda expression but rather a method reference. And they have indeed different restrictions.
While lambda cannot use non-final local variables, method reference has no such limitation.
Please check the details here: https://stackoverflow.com/questions/33052917/why-can-method-reference-use-non-final-variables
Tim Holloway wrote:An Interface is a contract. If a class implements an Interface, then it has promised that it will have implemented all of the methods defined in the Interface.
That's useful for a number of reason, including plug-replaceable components. And in particular test components.
If you have an interface definition you can construct a dummy or mock class that implements the indicated methods but does not have to actually do all the work that the "real" class does. That means that you can test your team's code without having to wait for the other team to deliver the "real" class.
Note that I distinguish between a "dummy" class and a "mock" class. In this context, a dummy class is simply a class that you implement yourself to test with. A Mock class is usually controlled by a mocking framework. Given a choice, I prefer dummy classes, but a mocked class can often be used in an environment where you need to pretend to connect to complex infrastructure and a dummy class can't be used.
Ng Sharma wrote:Best Answer.
https://stackoverflow.com/questions/4343202/difference-between-super-t-and-extends-t-in-java
Stephan van Hulst wrote:On a tangent: In general you don't need to worry about the A parameter. You only need to care about it if you implement your own Collector.
Tim Holloway wrote:Try this with 1:59 instead of 2:00. You might find it interesting. Indeed, try 1:59:59
Campbell Ritchie wrote:But Comparator is a functional interface.
Campbell Ritchie wrote:But Comparator is a functional interface.
Campbell Ritchie wrote:Have you seen the documentation for Collections#sort()?
Stephan van Hulst wrote:You need to tell us what part of the explanation is not clear to you, and explain to us why you think it is 0.