Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA PROBLEM This exercise is focused on making you more familiar with the usage of the lambda expressions in conjunction with Functional Interfaces (namely IntPredicate)

JAVA PROBLEM

This exercise is focused on making you more familiar with the usage of the lambda expressions in conjunction with Functional Interfaces (namely IntPredicate)

We already know that the following piece of code allows us to evaluate IntPredicate for a particular input value.

private static boolean applyPredicate(int value, IntPredicate predicate) { return predicate.test(value); } It tells us whether our integer value satisfies the condition conveyed by the predicate. e.g.

applyPredicate(2, x -> x > 100) returns false because 2 is not greater than 100 applyPredicate(15, x -> (x % 5 == 0)) returns true because 15 is divisible by 5

create a class TeenCount that implements the method public static int[] teenLess(int[] array) which takes in an array of integers as the input, applies the appropriate predicate over all the elements of the array and then returns a new array containing only those values which are not teens i.e. values which don't lie between 13 and 19 inclusive. Feel free to use the applyPredicate() method in your program

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

Students also viewed these Databases questions