In this problem, you will work with the java.util.function. DoubleToIntFunction
interface from the standard library.
In the Functions
class, provide two methods that yield objects implementing this interface.
Since each of them needs a class, and CodeCheck doesn't let you add arbitrary files, add the classes as non-public classes to Functions.java
.
Also, provide an implementation of the map
method that, given an array of double
values, yields an array of int
values that results from applying a DoubleToIntFunction
to each value.
The map
function would be more interesting with the Function
interface that can handle functions with arbitrary parameter and result types, but we didn't cover enough Java yet to do that.