PGoCareerGoCareer prep tools
Home
LoginSign up
  • Java
  • Python
  • AI
  • React
  • Angular
  • PHP
  • Node.js
  • SQL
  • DSA
  • HTML
  • CSS
  • JS
  • Spring
  • ML
  • MongoDB

Java · Theory

Java Lambda Expressions

← All stacks

Theory

232/270

Java Lambda Expressions

A lambda is a short way to write a small function you can pass around. Shape: (params) -> expression, or { statements }. It implements a functional interface — one abstract method. Example: names.forEach(n -> System.out.println(n));

Lambdas make collection and stream code shorter when they stay small. Method references (System.out::println) are even shorter sometimes. Don’t dump huge business logic inside a lambda.

Interview line — lambda = concise implementation of a functional interface.

Let's take this on the board with one tiny Main class — no extra files. Java Lambda Expressions — output: A then B then C. n -> println(n) is a real lambda — short function passed to forEach. Start from main, go line by line, and stop at each print. That output is the proof for Lambda Expressions.

Exam tip

Define lambda + show forEach one-liner.

Example

import java.util.Arrays;
import java.util.List;

public class Main {
  public static void main(String[] args) {
    List<String> names = Arrays.asList("A", "B", "C");
    names.forEach(n -> System.out.println(n));
  }
}

Java Lambda Expressions — output: A then B then C. n -> println(n) is a real lambda — short function passed to forEach.

Short notes

  • DefLambda = short function you can pass around. (args) -> body.
  • RuleNeeds a functional interface (one abstract method).
  • UseforEach, streams. Keep lambdas small.
  • RememberMethod reference System.out::println is sometimes shorter.

Questions

1

What is a lambda?

2

What does a lambda implement?

3

Write a forEach lambda.

Previous← Java 8 FeaturesNextJava Method References →
P

GoCareerGo

Utilities · Preparation Hub · Resume · CV · Tools — one workspace.

Workspace

DashboardProfilePreparation HubResume builderCV builderCareer planning

PDF Tools

Merge PDFSplit PDFCompress PDFImage to PDFAll toolsJobs

Image & QR

Compress ImageResize ImageQR ScannerQR GeneratorBlogIT interview prep

Company

FAQFeedbackContactPrivacyTermsSitemap

© 2026 GoCareerGo. Keep moving forward.