Need Help ?
Have a Question ?

(Solved): Create A Separate Implementation With Interfaces For The Lambda Expressions. Below Is The Code. Impo ...

Create a separate implementation with interfaces for the lambda expressions. Below is the code.

import java.util.ArrayList;

import java.util.Arrays;

import java.util.List;

import java.util.Map;

import java.util.TreeMap;

public class lab3 {

public void runExercises() {

System.out.println("Running exercise 1 solution...");


System.out.println("Running exercise 2 solution...");


System.out.println("Running exercise 3 solution...");


System.out.println("Running exercise 4 solution...");


} private void exercise1() {

List list = Arrays.asList("alpha", "bravo", "charlie", "delta", "echo", "foxtrot");

String result = -> Character.toString(s.charAt(0))).reduce("", (a, b) -> a + b);


} private void exercise2() {

List list = new ArrayList<>(Arrays.asList("alpha", "bravo", "charlie", "delta", "echo", "foxtrot"));

list.removeIf(s -> s.length() % 2 == 0);


} private void exercise3() {

List list = new ArrayList<>(Arrays.asList("alpha", "bravo", "charlie", "delta", "echo", "foxtrot"));

list.replaceAll(s -> s.toUpperCase());


} private void exercise4() {

Map map = new TreeMap<>();

map.put("c", 3);

map.put("b", 2);

map.put("a", 1);

StringBuilder builder = new StringBuilder();

map.forEach((key, value) -> builder.append(key + value));


} public static void main(String[] args) {

lab3 lab = new lab3();

lab.runExercises(); }


This code already includes lambda expression, you just need to implement this code with interface

Expert Answer

importjava.util.ArrayList; importjava.util.Arrays; importjava.util.List; importjava.util.Map; importjava.util.TreeMap; importjava.util.function.BiConsumer; publicclasslab3{ p
We have an Answer from Expert Buy This Answer $6