Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transact SQL Cookbook Help For Database Programmers

Authors: Ales Spetic, Jonathan Gennick

1st Edition

1565927567, 978-1565927568

More Books

Students also viewed these Databases questions