java core

Your blog category

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 »

Syntax and Structure of Lambda Expressions

Lambda expressions provide a clear and concise way to represent a functional interface using an anonymous function. Introduced in Java 8, they are used primarily to implement methods of functional interfaces in a simplified syntax. Basic Syntax Or, if the body contains multiple statements: Components of Lambda Expressions Parameters:The lambda can have zero or more

Syntax and Structure of Lambda Expressions Read More »

Java 8 Language Enhancements to Support Lambda Expressions

Java 8 Language Enhancements to Support Lambda Expressions  Java 8 introduced several major language enhancements to support lambda expressions and enable a functional programming style. These enhancements were necessary to allow lambda expressions to integrate smoothly with the existing object-oriented structure of Java. Below is a detailed overview of the key changes and features introduced:

Java 8 Language Enhancements to Support Lambda Expressions Read More »

PriorityQueue

The PriorityQueue interface in Java represents a priority queue based on the heap data structure. Unlike a regular queue, where elements are retrieved in a first-in-first-out (FIFO) manner, a priority queue retrieves elements based on their priority. The element with the highest priority is dequeued first. In Java, PriorityQueue is implemented as a priority heap,

PriorityQueue Read More »

Time and space complexity analysis of different operations.

Analyzing the time and space complexity of operations in various data structures is crucial for understanding their performance characteristics and making informed decisions based on your application’s requirements. 1. Array Operation Time Complexity Access (by index) O(1) Search (unsorted) O(n) Search (sorted, using binary search) O(log n) Insertion/Deletion (at end, if space) O(1) Insertion/Deletion (at

Time and space complexity analysis of different operations. Read More »

Lambda expressions with collections.

Lambda expressions in Java provide a concise way to express behavior as a method argument, especially when working with collections. They were introduced in Java 8 to facilitate functional-style programming, enabling developers to write cleaner and more readable code. Lambda expressions  provide a concise way to represent anonymous functions — a function without a name

Lambda expressions with collections. Read More »

Default and static methods in interfaces.

 Java 8 introduced two powerful features in interfaces: Default Methods – These are methods defined in an interface with a body (implementation). They allow you to add new methods to interfaces without breaking the existing implementation classes. Static Methods – These are utility methods that belong to the interface itself, not to instances. Both of

Default and static methods in interfaces. Read More »

Stream operations and transformations on collections

Stream Operations and Transformations on Collections in Java Java 8 introduced the Stream API, which provides a modern and efficient way to process collections (like List, Set, etc.). Stream operations help to filter, transform, sort, group, and reduce data in a clean and functional style. Two Types of Stream Operations Type Description Intermediate Returns a

Stream operations and transformations on collections Read More »

Scroll to Top