java core

Your blog category

Stream API and Lambda Expressions

Java 8 introduced two powerful features—Lambda Expressions and the Stream API—to support functional programming. These features brought a more declarative, concise, and expressive coding style to Java, particularly useful for processing data collections. Lambda Expressions  Lambda Expressions allow developers to treat functionality as a method argument or pass behavior as data. Instead of writing lengthy […]

Stream API and Lambda Expressions Read More »

Higher-Order Functions and Functional Composition

Higher-Order Functions and Functional Composition are concepts borrowed from functional programming paradigms and are supported primarily through Java 8’s lambda expressions and functional interfaces. 1. Higher-Order Functions in Java A higher-order function is a function that: Takes one or more functions as arguments, or Returns a function as its result. Java doesn’t have functions as

Higher-Order Functions and Functional Composition Read More »

Variable capture and effectively final variables

In Java, especially when dealing with lambda expressions, anonymous classes, or inner classes, the concept of variable capture and effectively final variables becomes very important. What is Variable Capture? Variable capture refers to the process where a lambda expression or inner class accesses variables from the enclosing scope (usually local variables from a method). These

Variable capture and effectively final variables Read More »

Target Typing and Type Inference with Lambda Expressions

Lambda expressions, introduced in Java 8, simplify the process of writing anonymous classes and implementing functional interfaces. Two core concepts that enable their functionality are target typing and type inference. These allow the compiler to deduce the types involved in lambda expressions, resulting in cleaner and more readable code. What is Target Typing? Target typing

Target Typing and Type Inference with Lambda Expressions Read More »

Method References and Constructor References

Method References and Constructor References are features introduced in Java 8 that make lambda expressions even more concise. They allow you to refer to methods or constructors without invoking them, offering a clean and readable syntax for functional programming. 1. Method References A method reference is a shorthand notation of a lambda expression to call

Method References and Constructor References Read More »

Lambda Expressions Examples

Basic Java programs demonstrating different use cases of Lambda expressions. Simple Lambda Expression for Addition Lambda Expression for String Concatenation Lambda Expression with No Parameters Lambda Expression for Finding Maximum of Two Numbers Lambda Expression for Filtering Even Numbers Lambda Expression for Sorting a List Lambda Expression for Iterating Over a List Lambda Expression for

Lambda Expressions Examples Read More »

Functional Interfaces

Functional Interfaces are a core concept introduced in Java 8 to support lambda expressions and functional programming. A functional interface is an interface that contains exactly one abstract method, although it can have multiple default or static methods. Important Points about Functional Interfaces Single Abstract Method (SAM):A functional interface must have exactly one abstract method.

Functional Interfaces Read More »

Scroll to Top