-
Notifications
You must be signed in to change notification settings - Fork 0
Java SE Home
Java Standard Edition(SE) Home
Eager vs Lazy Stream Operations
In the Streams API, operations that return a stream are lazy, and operations that return a non-stream result (or return no result, such as forEach()) are eager.
Java allows to define a class within another class.
Local classes are classes that are defined in a block, which is a group of zero or more statements between balanced braces. Typically local classes are defined in the body of a method.
Local class can be defined inside any block (see Expressions, Statements, and Blocks for more information).
Static initializers or member interfaces can not be declared in a local class. But a local class can have static members provided that they are constant variables.
Anonymous classes are local classes without names. Use anonymous class if a local is used only once.
Serialization of inner classes, including local and anonymous classes is strongly discouraged because compiler generic synthetic constructs while compiling nested classes.
Lambda expressions are lexically scoped i.e., declarations in the lambda expressions are interpreted as they are present the enclosing environment. Lambda expressions do not introduce new scope, they will have same scope as enclosing block.