21.0k views
1 vote
Create a public non-final class named Streamer. You should implement one class method: filterStrings. It should accept a single parameter: a Stream of Strings (Stream). It should also return a Stream of Strings, but: only those that are longer than 8 characters and with each member of the stream converted to lowercase You may want to review yesterday’s lecture and Java’s official stream documentation, in particular the map and filter functions. You will need to import java.util.stream.Stream. Do not terminate the stream: simply return it from your function.

1 Answer

2 votes

Answer:

See explaination

Step-by-step explanation:

/ Streamer.java

import java.util.stream.Stream;

public class Streamer {

//required method

public static Stream<String> filterStrings(Stream<String> stream) {

//filtering out the strings from stream where length is less than or

//equal to 8, and then converting all strings in the resultant stream

//to lower case using map()

stream = stream.filter(e -> e.length() > 8).map(String::toLowerCase);

return stream;

}

}

User Darvish Kamalia
by
5.6k points