Java Tutorial · Revision notes

Java 8 Features

Java 8 added functional-style programming to Java: lambda expressions, functional interfaces, the Stream API, Optional and method references. Together they replace verbose loops and anonymous classes with short, readable pipelines.

Quick revision

  • Lambda: (params) -> body; captured locals must be effectively final
  • Functional interface: one abstract method; Predicate, Function, Consumer, Supplier
  • Stream = source + lazy intermediates + one terminal; single use
  • collect(groupingBy / joining / toList), reduce, mapToInt().sum()
  • Optional: of / ofNullable / empty; orElse vs orElseGet; avoid get()
  • Method refs: Class::static, obj::method, Class::instance, Class::new
Read the full Java 8 Features notes on Doubtclip →