lambda
14 tutorials tagged “lambda”.
- Anonymous Class vs LambdaAnonymous classes and lambdas can both implement an interface inline. Learn the differences in syntax, this, state, interfaces supported and performance.
- Built-In Functional Interfaces in JavaThe java.util.function package: Predicate, Function, Consumer, Supplier, UnaryOperator, BinaryOperator and BiFunction, with their methods and examples.
- Comparator Chaining in JavaComparator chaining sorts by several keys with thenComparing. Learn how ties are broken, how reversed works in a chain, and how to handle nulls.
- Comparator Interface in JavaThe Comparator interface defines custom sort orders outside a class. Learn compare, lambdas, Comparator.comparing, reversed and nullsFirst, with examples.
- Composing Functions in JavaBuild bigger functions from small ones with andThen, compose, and, or, negate, Predicate.not and Function.identity. Learn each with examples.
- Effectively Final Variables and Lambda CaptureLambdas can use local variables only if they are effectively final. Learn what that means, why Java requires it, and the usual workarounds.
- forEach Method in JavaThe forEach method runs a lambda for every element of a collection, map or stream. Learn Iterable.forEach, Map.forEach, Stream.forEach and their limits.
- Functional Interfaces in JavaA functional interface has exactly one abstract method and can be implemented with a lambda. Learn the rules, @FunctionalInterface, and how to write your own.
- How Lambdas Are CompiledLambdas don't become anonymous classes. Learn how javac turns them into private methods plus an invokedynamic call, and how LambdaMetafactory links them.
- Java 8 FeaturesJava 8 brought lambdas, functional interfaces, method references, streams, Optional, default methods and a new date and time API. Learn each with examples.