From the course: Java: Lambdas and Streams

Unlock the full course today

Join today to access over 25,000 courses taught by industry experts.

Using existing interfaces

Using existing interfaces - Java Tutorial

From the course: Java: Lambdas and Streams

Using existing interfaces

- [Instructor] Most of the time, you actually won't need to write your own functional interfaces. Java's already got quite a few implementations of functional interfaces that you can use. In the previous video, I created an interface called Calculator and this has a single method, calculate that takes two ints as inputs and returns an int, but Java's actually already got a ready-made interface that does exactly this. There's a package called java.util.function, which contains lots of useful functional interfaces. So, let's take a look at the documentation at docs.oracle.com for this package, java.util.function. If you take a look at this page you can see a list of the ones they already have, and actually most of your use cases for writing lambdas will probably be covered by one of the ones in here. For most lambdas, you basically want to pass in a certain number of arguments and either return something or return nothing.…

Contents