World 15 of 26 · Intermediate

λ Lambdas & Functional Java

11 Java concepts, each explained step by step with real code, a common trap and practice questions.

  1. Lambda syntax(a, b) -> a + b, block bodies, type inference from the target.
  2. Core functional interfacesFunction, Predicate, Consumer, Supplier, BiFunction, UnaryOperator, BinaryOperator.
  3. Primitive functional interfacesIntPredicate, ToIntFunction… avoid boxing.
  4. Method referencesStatic, bound instance, unbound instance and constructor references.
  5. Effectively final captureLambdas can only capture locals that are never reassigned.
  6. this in lambdas vs anonymous classesA lambda's this is the enclosing instance.
  7. Composing functionsandThen, compose, Predicate.and/or/negate, Function.identity.
  8. OptionalRepresenting absence: map, flatMap, orElse vs orElseGet, orElseThrow; not for fields or parameters.
  9. Checked exceptions in lambdasStandard functional interfaces cannot throw checked exceptions.
  10. Higher-order functionsMethods that take or return functions; strategy via lambdas.
  11. Comparator with lambdasComparator.comparing, nullsFirst, chaining.