Angelika Langer - Training & Consulting
HOME | COURSES | TALKS | ARTICLES | GENERICS | LAMBDAS | IOSTREAMS | ABOUT | CONTACT | Twitter | Lanyrd | Linkedin
About Angelika Langer  
HOME 
GENERICS 

LAMBDAS

    CONTENT
    FAQ
    LAMBDA TUTORIAL
    LAMBDA REFERENCE
    STREAM TUTORIAL
    STREAM REFERENCE
 
IOSTREAMS 
ABOUT 
CONTACT
Lambda Tutorial & Reference - Questions & Answers

This is a webpage devoted to lambda expressions in Java (a new language feature) and streams (new abstractions in the JDK's collection framework) - both were added to Java on March 18, 2014 with release 8. If you want to provide feedback or have any questions regarding lambda expressions in Java feel free to send me EMAIL or use the LAMBDA QUESTION form.
The Lambda Tutorial is available in PDF format (330KB) and in EPUB format (410KB) .
The Lambda Reference (note: it is an incomplete draft version) is available in PDF format (1200KB) .


Keep in mind that part of the Lambda/Streams Tutorial & References is still in draft version.

Lambda Tutorial & Reference - Questions & Answers

Questions & Answers

What is the closure debate?
A discussion in 2006-2009 of three proposals for a lambda-like language feature; all three proposals were discarded.
Why does the Java programming language need lambda expressions?
Because many modern programming languages have a similar language features., as a preparation for fine-grained automated parallelization on multi-core hardware, in particular for bulk operations on collections.
What is a lambda expression in Java?
A concise notation for a method without a name.
What do lambda expression and anonymous inner classes have in common?
Both are used to implement ad-hoc functionality aka anonymous methods.
What is a method? What is a function? How do they differ?
Functions are executed, but also passed around like data. They do not mutate data; they just produce new results. The order of their invocation does not matter.
Methods are executed and may mutate data and produce side effects. The invocation order matters.
What is a pure function as opposed to an impure function?
A pure function never modifies any data, whereas an impure function may produce side effects.
How is a lambda expression represented at runtime?
By a lambda object; both the lambda object and its type are dynamically created by the virtual machine at runtime.
What is the type of a lambda expression?
In isolation a lambda expression has no definite type; its type depends on the context in which it appears and is inferred by the compiler .
What is the target type of a lambda expression?
A type to which the lambda expression can be converted in a given context; the target type must be a functional interface type.
What is a functional interface?
An interface with a single abstract method.
How does the syntax of lambda expressions differ from the syntax of anonymous inner class?
The syntax of lambda expressions is less verbose and more readable.
For an anonymous inner class type definition and instance creation are tied together. How are lambda expression translated?
Creation of the lambda object and its type  is implicitly taken care of by the virtual machine; it is done at runtime.
Anonymous inner class can have bindings to variables of the enclosing scope.  Is the same true for lambdas?
Yes, lambda expressions can capture effectively final variables from their enclosing scope and can bind to the enclosing instance via  this and  super .
An anonymous inner class is a name scope of its own. How about lambda expressions?
Lambda expressions are part of the scope in which they appear; they are not scopes of their own.
What does  this refer to in a lambda expression?
It refers to the enclosing instance (different from an anonymous class where  this refers to the inner class's instance).
What do we need lambda expressions in Java for?
To enable convenient use of the overhauled collection framework in general and it parallel bulk operations in particular.
What is a bulk operation?
An operation that concern many or all elements in a sequence.
What is internal and external iteration?
External iteration uses an iterator for access to all sequence elements. Internal iteration is performed by the sequence itself; the user just supplies an operation to be applied to all sequence elements.
What is a stream?
An abstraction from the JDK collection framework that supports bulk operations with internal iteration.  There are sequential and parallel streams.
What is filter-map-reduce?
Typical bulk operation on sequences with internal iteration.
What is fluent programming?
A programming technique that chains operations, i.e., a style where operations return a value that allows the invocation of another operation.
What is declarative programming?
A programming  style that describe what to rather than how to do it.
What is pipelining?
An optimization for chained operations. Rather than looping over all elements in the sequence repeatedly (per operation in the chain) the entire chain of operations is applied to each element in just one pass over the sequence.
What is the execute-around-method patter?
A programming technique for eliminating code duplication.
What is a default method?
An interface method with a default implementation.
What are default methods intended for?
The are used for interface evolution, i.e., extending existing interfaces with additional methods without breaking any implementing classes.
Does multiple inheritance lead to problems with ambiguities?
Yes, there arise ambiguities with inheritance of default methods, but they are easily resolved using the right syntax.
Does Java with default methods have multiple inheritance (of implementation)?
Yes, a class can inherit non-abstract methods from one superclass and multiple interfaces.
CONTENT NEXT   INDEX
 
  © Copyright 1995-2014 by Angelika Langer.  All Rights Reserved.    URL: < http://www.AngelikaLanger.com/Lambdas/FAQ.html  last update: 26 Nov 2014