Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started