Author name: Ramesh Fadatare

Java 8 – Filter a Stream Using Lambda Expressions

Introduction Filtering a stream is a fundamental operation in Java, especially when you need to extract elements from a collection that match specific criteria. Java 8 introduced the Stream API, which provides a powerful way to process data in a declarative manner. One of the key features of the Stream API is the ability to …

Java 8 – Filter a Stream Using Lambda Expressions Read More »

Java 8 – Convert Set to Comma-Separated String

Introduction Converting a Set to a comma-separated String is a common requirement in Java, especially when you need to display the contents of a Set, generate a CSV output, or simply log the data. Java 8 introduced the Stream API, which provides a powerful and flexible way to convert collections into formatted strings. In this …

Java 8 – Convert Set to Comma-Separated String Read More »

Java 8 – Convert a Collection to a String

Introduction Converting a collection to a string is a common task in Java, especially when you need to display the contents of a collection, log data, or create a formatted output. Java 8 introduced the Stream API, which provides a powerful and flexible way to convert collections to strings, offering various options for customization, such …

Java 8 – Convert a Collection to a String Read More »

Java 8 – Create an Immutable List

Introduction Immutable lists are a fundamental concept in programming, particularly useful when you need to ensure that the contents of a list cannot be modified after it has been created. This is especially important in multi-threaded environments where data consistency is crucial. While Java has traditionally provided ways to create immutable collections, Java 8 introduced …

Java 8 – Create an Immutable List Read More »

Java 8 – Flatten Collections with FlatMap

Introduction When working with nested collections, such as a list of lists, you may often need to flatten these collections into a single list. Java 8 introduced the flatMap method in the Stream API, which allows you to achieve this in a clean and efficient manner. Flattening collections is particularly useful when processing hierarchical data …

Java 8 – Flatten Collections with FlatMap Read More »

Java 8 – Shuffle Elements in a List

Introduction Shuffling the elements in a list is a common operation, especially in scenarios where you need to randomize the order of items, such as in games, simulations, or simply to introduce randomness in data processing. Java provides a straightforward way to shuffle a list using the Collections.shuffle() method. With the introduction of Java 8, …

Java 8 – Shuffle Elements in a List Read More »

Scroll to Top