Q. What is the purpose of the flatMap() method in a stream pipeline?

  • (A) To combine multiple streams into a single stream
  • (B) To transform each element of a stream into a new stream
  • (C) To remove duplicates from a stream
  • (D) To sort the elements of a stream
πŸ’¬ Discuss
βœ… Correct Answer: (B) To transform each element of a stream into a new stream
Explanation: The flatMap() method allows you to replace each element of a stream with a new stream, which is then flattened into a single stream.
Explanation by: Pushkar
The flatMap() method allows you to replace each element of a stream with a new stream, which is then flattened into a single stream.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
270
Total Visits
πŸ“½οΈ
3 y ago
Published
πŸŽ–οΈ
Pushkar
Publisher
πŸ“ˆ
86%
Success Rate