Skip to content

Java SE Home

peddi-dev edited this page Mar 12, 2019 · 10 revisions

Java Standard Edition(SE) Home

Java Streams API

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.

Nested Classses

Java allows to define a class within another class.

Java Local Classes

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

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.

Lamda Expressions

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.

Clone this wiki locally