From the course: Data Science for Java Developers

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Solution: Manipulating data

Solution: Manipulating data - Java Tutorial

From the course: Data Science for Java Developers

Solution: Manipulating data

(soft music) - [Instructor] Okay, so I'm going to walk you through how I went about solving this problem. As I mentioned in the challenge video. the first thing that I did was get a list of all of the unique memberNumbers and the way that I did that, looks something like this. I started off by saying List<String> allMemberNumbers equals and then I said, groceries.stream and then I used map to map each grocery record to its memberNumber. So I said, grocery.memberNumber. And finally I said .collect and then collectors.toSet because sets in JavaScript ignore duplicates. So that's very useful for helping us remove the duplicate memberNumbers in our data set. Now, since this is a set, what we had to do then since we want it to be a list format as you'll see later on is we had to say new array list and convert this set into an array list. So now that we have a list of all of our memberNumbers the next thing I did is…

Contents