import java.io.File; import java.io.FileNotFoundException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; import java.util.stream.Collectors; public class CorruptingLambdas { public static void main(String[] args) throws FileNotFoundException { // Words data ArrayList words = new ArrayList(); // Read input data // TODO // Count occurances of words containing "CAT" long catCount = 0; // TODO - Convert words to a stream, use the method filter() with a lambda // expression, and then use the method count(). System.out.println("Cat words before: " + catCount); // Make a new collection of words that replaces "DOG" with "CAT" ArrayList corruptedWords = words; // TODO - Convert words to a stream, use the method map() with a lambda // expression, and then use the method // collect(Collectors.toCollection(ArrayList::new)) to get an arraylist from // the stream. // Reverse sort that collection // TODO - Use the method Collections.sort() with a lambda expression // Count occurances of words containing cat again // TODO - Convert corruptedWords to a stream, use the method filter() with a // lambda expression, and then use the method count(). System.out.println("Cat words after: " + catCount); // Output to a new file // TODO - Convert corruptedWords to a stream, and then use the method // forEach() with a lambda expression } }