This year I will teach students about lambda expressions (in java). I am trying to explain how they are interpreted by the JVM and what they unfold into.
String firstString = "this is a lambda example!"; String secondString = "and we compare to this, as well"; Function<String, Double> comparison = (String third) -> (third.compareTo(firstString) + third.compareTo(secondString)) / 2.0;
would create a function that gives the average of the comparison between a given string and
secondString. I've tried to explain to a selection of students (as a Proof of Concept of my planned lesson, so only 4-5 students) that lambda expressions just make things look better but they think that it's a new way to do this. I am trying to explain that lambda expressions are simply a shortened way to write something a bit bigger.
So my question is, how do I explain what lambda expressions exactly are, in such a way that shows the students how these expressions are interpreted by Java?