The Sevilla Java User Group is working together towards completing the
Java 8 MOOC on
lambdas and streams. As part of this, we’re running three sessions
during the course so we can, as a group, ask questions about the lectures, get help with the homework, and (if we’re
feeling very smart!) help people who may be struggling (or might not have watched the videos).
Last night we had the first session which went really well. We had a small-ish group, about half of whom had
completed the homework and the quiz (for the first lesson) and half had not. We worked through the homework exercises
together, saw how there were multiple solutions for each problem, and explored how to balance conciseness with
longer, more descriptive code.
On the whole people thought the videos for the course were very clear and well-explained, although we also went
through how to run the videos at 1.5 speed, as most people wanted to run through them faster! I thought the pace of the
videos was especially good for those who aren’t so comfortable with listening in English, and it’s easy to add
subtitles and speed it up if you feel comfortable with the material.
The first lesson covers lambdas, and their use in some of the new Java 8 methods (specifically on collections, but
The areas we discussed most, the ones that needed more clarity were:
- Functional Interfaces:
what does Single Abstract Method (SAM) really mean? Also, we
were interested in the “exception” of methods declared on
Object as well as an interface (e.g.
equals()), but we
to the conclusion that it was easier to simply think of looking for only one method without any form of
implementation at all - methods defined on
Object must have an implementation, since
Object is not an
abstract class or interface.
- Method References: we looked at
examples of the three types that aren’t constructor references, what they look like in lambda form and how they
differ. Method references are… not difficult to understand, but do look a bit awkward in the code if you’re not
used to them, and can be confusing as all your types, parameters and return values disappear.
- Parallel execution: The first lesson talks a lot about how lambdas are here to make parallelisation and
concurrency easier for developers, so obviously there was a question about how the code in the homework examples would
be executed in a multi-CPU environment. I assumed (although I’m waiting for clarification) that methods like
removeIf are not parallelised, since in the case of Streams you have to explicitly state you want to go parallel.
We also talked a bit about
though the lesson didn’t cover Streams at all. We wanted to understand a bit more about the pros and cons of going
Of course, I also snuck in some demos of IntelliJ IDEA’s awesomeness, including
its magical support for creating lambdas and turning things into (and from) method references.
It was a great, collaborative session, with most people getting a chance to demonstrate their code (if they wanted
to!). And at the end we had solutions to the five exercise problems and had discussed all the areas people wanted
more clarity on.