Many are getting quite excited to see this functional programming & mostly have just got the
exposure & that too still working with Java8, they like to ask the questions on this & such
questions which possibily they came across recently over the internet or in their interviewes.
Well the question was asked by some P. Jain from Xebia in one interview -
You are given a list of city names & you need to print those names only, which are getting repeated in the given list, i.e. you need to provide the duplicate names only.
e.g. : List<String> names = Arrays.asList("delhi", "pune", "pune", "jaipur", "delhi");
In above list, ans should be "pune" & "delhi".
As suggested on - How to find duplicate elements in a Stream in Java - GeeksforGeeks
There can be different ways to get the result but 2 of those are mentioned below which seem clean-
exposure & that too still working with Java8, they like to ask the questions on this & such
questions which possibily they came across recently over the internet or in their interviewes.
Well the question was asked by some P. Jain from Xebia in one interview -
You are given a list of city names & you need to print those names only, which are getting repeated in the given list, i.e. you need to provide the duplicate names only.
e.g. : List<String> names = Arrays.asList("delhi", "pune", "pune", "jaipur", "delhi");
In above list, ans should be "pune" & "delhi".
As suggested on - How to find duplicate elements in a Stream in Java - GeeksforGeeks
There can be different ways to get the result but 2 of those are mentioned below which seem clean-