Please follow the comments throughout this code.
Use the driver class supplied and follow the instructions in the comments.
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"); 1/this call to repeat passes a lambda and prints a line of 10 # symbols repeat (10, () -> System.out.print("#")); I/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 I/Hint: Use the ternary operator //Call accept I/Create a Function that accepts an Integer argument and returns the square of that Integer //Call apply 1/Create a Function that takes an Integer argument and returns the negative of the argument 17 call apply //Now use the default andThen method of Function to square an integer and then negate it 1/Hint: Use your square method to call andThen 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 //call apply //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 //Call test //Now use the default and method of BiPredicate to test if two strings are the same length and start with the same character //Now use the default or method of BiPredicate to test if two strings are the same length or start with the same character //Create a Comparator to compare strings by length (short to long) //Hint: subtract the lengths //Now call Collections. sort to sort the supplied array by string length //call the forEach method of the ArrayList class and pass an appropriate lambda to print each word in the supllied list I/Hint: The lambda must be a Consumer } private static void repeat(int n, Runnable action) { for (int i = 0; i<>