From the course: Functional Programming with Java

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Functions as data

Functions as data - Java Tutorial

From the course: Functional Programming with Java

Start my 1-month free trial

Functions as data

So now that we've spent a good bit of time learning about Java's function interfaces and how they allow us to assign functions to variables. Let's take a look at a few things that just the simple shift in mindset alone allows us to do. One thing that functional interfaces allow us to do is assign the definition of a function dynamically at runtime. So to illustrate this let's think about a real world example. Let's say that we're writing a program that loads data from a server, let's say that it loads data about a person or something like that. The only problem is that this process takes a long time and during development or while running tests, it can really slow us down to have to wait for our program to load this data every time. The good news is that using the concept of functions as data that we've been learning about in the past few videos. We can dynamically change the definition of the function that loads our data based on the environment it's running in. And here's how. So…

Contents