Answered step by step
Verified Expert Solution
Link Copied!

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.
1.
Write a static method sumOdd that given a List of integers computes the sum of the
values that are odd.
2
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 [0.2, Math.PI], and
the second element is the average of the values of lst in the range [10,100].
3
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.
4
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.
5
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, i.e. 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases And Information Systems 1 International Baltic Conference Dbandis 2020 Tallinn Estonia June 19 2020 Proceedings

Authors: Tarmo Robal ,Hele-Mai Haav ,Jaan Penjam ,Raimundas Matulevicius

1st Edition

303057671X, 978-3030576714

More Books

Students also viewed these Databases questions