Question: import java.util. function.*; import java.util.ArrayList; /** public class Driver public static void main(String[] args) ArrayList words = new ArrayList>(); words.add(interface); words.add(class); words.add(inheritance); words.add(abstract); //this call

 import java.util. function.*; import java.util.ArrayList; /** public class Driver public static

import java.util. function.*; import java.util.ArrayList; /** public class Driver public static void main(String[] args) ArrayList words = new ArrayList>(); words.add("interface"); words.add("class"); words.add("inheritance"); words.add("abstract"); //this call to repeat passes a lambda and prints a line of 10 # symbols repeat (10, () -> System.out.print("#")); 1/Write a call to repeat that prints the phrase "Lambdas ar fun!" 5 times, one per line [/The Consumer first prints the first character of the input string Consumer first = inString -> System.out.print(instring.charAt(0)); first.accept("Java"); 1/Create a Consumer that prints the last character of the input string //Call the accept method 1/Create a Consumer that prints the first five characters of a String or the entire string if length less than five 1/Hint: Use the ternary operator //Call accept 1/Create a Function that accepts an Integer argument and returns the square of that Integer 1/Call apply 1/Create a Function that takes an Integer argument and returns the negative of the argument //Call apply 1/Now use the default and Then method of Function to square an integer and then negate it 1/Hint: Use your square method to call and then passing the negate method which calls apply 1/Create a BiFunction that takes two Double arguments and returns the first argument raised to the power of the second 1/Call apply 1/Create a BiPredicate that accepts two String arguments and returns true if they are the same length //Call test 1/Create a BiPredicate that accepts two String arguments and returns true if they start with the same character I/Call test 1/Now use the default and method of BiPredicate to test if two strings are the same length and start with the same character 1/Now use the default or method of BiPredicate to test if two strings are the same length or start with the same character 1/Create a Comparator to compare strings by length (short to long) 1/Hint: subtract the lengths 1/Now call Collections.sort to sort the supplied array by string length 1/call the forEach method of the ArrayList class and pass an appropriate lambda to print each word in the supllied list 1/Hint: The lambda must be a Consumer } private static void repeat(int n, Runnable action) for (int i = 0; i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!