java core

Your blog category

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 »

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 »

Using streams to process collections efficiently.

Using streams in Java allows for efficient and concise processing of collections and other data sources. Streams provide a declarative approach to perform operations on sequences of elements, leveraging functional programming concepts. Operation Traditional Approach Stream API Approach Description Filtering Loop with if condition collection.stream().filter(e -> e.startsWith(“A”)) Filters elements that match a condition. Mapping Loop

Using streams to process collections efficiently. Read More »

Implementing custom iterators

Implementing custom iterators in Java involves creating classes that implement the Iterator interface or extend classes that provide iterator functionality (Iterator or ListIterator). Custom iterators are useful when you need to define specialized traversal logic or filter elements during iteration. Let’s create an example of a custom iterator for a list of student names. Implementing

Implementing custom iterators Read More »

Scroll to Top