All the instructions are within the code. import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.TreeMap;
Question:
All the instructions are within the code.
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
public class lab4 {
/**
* Run the exercises to ensure we got the right answers
*/
public void runExercises() {
System.out.println("Running exercise 1 solution...");
exercise1();
System.out.println("Running exercise 2 solution...");
exercise2();
System.out.println("Running exercise 3 solution...");
exercise3();
System.out.println("Running exercise 4 solution...");
exercise4();
}
/**
* All exercises should be completed using Lambda expressions and the new
* methods added to JDK 8 where appropriate. Use method references rather than full
* lambda expressions wherever possible.
* Implement interfaces for each of your lambda functions and show that you can run them from a tester class
*/
/**
* Exercise 1
*
* A string needs to be created that consists of the first letter of each word in the
* list of Strings provided.
*/
private void exercise1() {
List
// Write code in these empty lines
}
/**
* Exercise 2
*
* Remove the words that have even lengths from the list.
*/
private void exercise2() {
List
// Write code in these empty lines
}
/**
* Exercise 3
*
* Replace every word in the list with its upper case equivalent.
*/
private void exercise3() {
List
// Write code in these empty lines
}
/**
* Exercise 4
*
* Convert every key-value pair of the map into a string and append them all
* into a single string, in iteration order.
*/
private void exercise4() {
Map
map.put("c", 3);
map.put("b", 2);
map.put("a", 1);
// Write code in these empty lines
}
/**
* Main entry point for application
*
* @param args
* the command line arguments
*/
public static void main(String[] args) {
lab4 lab = new lab4();
lab.runExercises();
}
}
Microeconomics An Intuitive Approach with Calculus
ISBN: 978-0538453257
1st edition
Authors: Thomas Nechyba