java core

Your blog category

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 »

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 »

Lambda Expressions Vs Anonymous Inner classes

Lambda expressions and anonymous inner classes in Java are used to provide implementation of interfaces—particularly for functional interfaces (interfaces with a single abstract method). However, they differ in syntax, readability, performance, and use cases. Feature Lambda Expression Anonymous Inner Class Syntax Concise and functional-style syntax Verbose, requires boilerplate code Introduced In Java 8 Java 1.1

Lambda Expressions Vs Anonymous Inner classes Read More »

Scroll to Top