Question: public interface NumFilter boolean filter (Double x); public interface NumOperation Double filter (Double x);) Lambda expressions have a type, and the above interface definition are

public interface NumFilter boolean filter (Double x); public interface NumOperation Double filter (Double x);) Lambda expressions have a type, and the above interface definition are a way of defining such a type. You can also use the functional interfaces already predefined in the Java API if you wish to In this exercise you will practise filter and operation lambdas with 1D and 2D number arrays. The initial scenario is data cleaning i.e. we have some data that needs to be fixed. For example missing values that have to be set to zero or set to some other value 1. Write a lambda expression that checks whether a number (Double) is less than 200 2. Write code that sets the above expression to a variable of type NumFilter. Then write test code that applies this variable to a value then prints it. 3. Write a lambda expression that checks whether a number (Double) is zero 4. Write code that sets the above expression to a variable of type NumFilter. Then write test code that applies this variable to a value then prints it. 5. Write a lambda expression that checks whether a number (Double) is null 6. Write code that sets the above expression to a variable of type NumFilter. Then write test code that applies this variable to a value then prints it. You should now have three lambda filters. The following steps will not use lambdas, it is here to show you the long way of doing somethi called nums. 7. Create an array of Double with the values: 100, 250, 0, 125, null, 500, 0,400 8. Write a block of code that counts how many numbers in nums are 200 9. Write a block of code that counts how many numbers in nums are zero 10. Write a block of code that counts how many numbers in nums are null. Next we redo the above using a lambda. 11. Write a block of code that using a filter, applies that filter to nums, then counts how many numbers passed the filter 12. Write test code for the above block that uses your three lamdas from steps 1- 6
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
