(Solved) : Please Finish Todo Sections Following Java Code See Main Function Needs Please Import Java Q43980653 . . .
Please finish the TODO sections for the following java code. seeMain for what each function needs to do please
import java.util.List;
import java.util.function.Function;
import java.util.function.BiFunction;
import java.util.function.Predicate;
import java.util.Comparator;
public class secondAssignment {
static <U,V> List<V> map(Iterable<U> l,Function<U,V> f) {
//TODO
return null;
}
static <U,V> V foldL(V e, Iterable<U>l,BiFunction<V,U,V> f){
//TODO
return null;
}
static <U,V> V foldR(V e, Iterable<U>l,BiFunction<U,V,V> f){
return null;
}
public static void main(String[] args) {
// (1) Use map to implement thefollowing behavior (described in Python). i.e given aList<T> create a List<Integer> of the hashes of theobjects.
// names = [‘Mary’, ‘Isla’,’Sam’]
// for i inrange(len(names)):
// names[i] = hash(names[i])
// (2) Use foldL to calculate thesum of a list of integers.
// i.e write a method: intsum(List<Integer> l)
// (3) Use foldR to concatenate alist of strings i.e write a method
// String s (List<String>l)
//TODO
}
}
class Person{
final int salary;
final String name;
Person(int salary, String name){
this.salary = salary;
this.name = name;
}
int getSalary() { return salary; }
String name() { return name;}
}
Expert Answer
Answer to Please finish the TODO sections for the following java code. see Main for what each function needs to do please import j…
OR