Question: Here are some JAVA Problems - - For each of the following exercises provide a solution that uses methods of the Stream interface. 1 .
Here are some JAVA Problems
For each of the following exercises provide a solution that uses methods of
the Stream interface.
Write a static method sumOdd that given a List of integers computes the sum of the
values that are odd.
Implement a generic record class ImmutablePair. Then, write a static
method someCalculation not in ImmutablePair that given a List
lst returns an object of ImmutablePair class. The first element of the
pair is the number of elements of lst in the range Math.PI and
the second element is the average of the values of lst in the range
Write a static method repl that given a List xs of Object and a integer n returns an
arraylist containing the elements of xs replicated n times in any order.
Hint: consider the flatMap method of Stream.
Write a function titlecase that given a list of strings converts it to titlecase by
uppercasing the letters of every word that starts with an a
Write a static method replaceWord that given the name of a text file String
fileName a word String word and a replacement String repl prints the content
of fileName where each occurrence of word is replaced with repl. Note that the
structure, ie lines, of fileName must be preserved. Test your method with the
file people.csv replacing for example true with false.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
