Skip to content
This repository was archived by the owner on Apr 2, 2026. It is now read-only.

Latest commit

 

History

History
90 lines (46 loc) · 2.09 KB

File metadata and controls

90 lines (46 loc) · 2.09 KB

λ Lambda Expressions in Java

GitHub stars GitHub forks

Lambda

Embrace Functional Programming in Java

Write concise, readable code with lambda expressions and functional interfaces


🎯 About

Lambda Expressions (Java 8) provide a clear and concise way to implement functional interfaces. Write less code, achieve more!

📝 Syntax

// No parameters
() -> System.out.println("Hello!")

// One parameter
x -> x * x

// Multiple parameters  
(x, y) -> x + y

📚 Examples

// Traditional vs Lambda
Runnable r1 = new Runnable() {
    public void run() { System.out.println("Old way"); }
};

Runnable r2 = () -> System.out.println("Lambda way!");

// Collections
List<String> names = Arrays.asList("Alice", "Bob");
names.forEach(name -> System.out.println(name));
names.forEach(System.out::println); // Method reference

🔧 Functional Interfaces

Interface Method Purpose
Consumer accept(T) Takes input, no output
Supplier get() No input, returns output
Function apply(T) Input to output
Predicate test(T) Returns boolean

🛠️ Technologies

Java 8+ | Eclipse/IntelliJ IDE

📬 Contact

LinkedIn Gmail


Keywords: Java Lambda Functional-Programming Java8 Stream-API Functional-Interface