Skip to main content

Posts

Showing posts from June 22, 2019

Cracking Java8 Stream Interview Question

Greetings!

I have faced many interviews (too many to be frank) in my career as a software developer. In most of those interviews I have been asked to write a pseudo code for a given problem and implement it in Java. With Java8, this implementation mostly should be in Java8.
When I look back all those questions it can be simplified as below. (difficulty may be vary though).

Iterate over a given collection (stream)Filter the given data (filter)Transform into another format (map, reduce)Collect data into a collection (collect)or End the stream (forEach, min, etc)
Is this familiar to you? This should be. This is what we do in our daily work. But, if you are blindly using it you will see it as a difficult question to answer.
You need to have good understanding about intermediate and terminal operations. And, you need to really practise and use in daily work. It is meaningless to pass an interview without knowing these.
java-8-streams-intermediate-operations
java-8-streams-terminal-operations