This repository contains implementations of various tasks using Java's Stream API and Lambda expressions. The project demonstrates functional programming concepts through different data processing operations, including filtering, sorting, generating sequences, and merging streams.
This project showcases different functional programming techniques in Java using Streams and Lambda expressions including:
-
Filtering names with odd indices and formatting them.
-
Sorting names in descending order while converting them to uppercase.
-
Extracting and sorting numbers from an array of strings.
-
Generating a sequence of random numbers using a linear congruential generator.
-
Merging two streams by interleaving their elements.
-
Efficient data processing using Java Streams.
-
Functional programming with lambda expressions.
-
Sorting and filtering collections.
-
Generating sequences with custom logic.
-
Merging and manipulating streams.
-
Using Optional class.
-
Java
-
Java Streams API
-
Lambda Expressions
-
Optional class
-
Functional Programming Concepts
-
Collections Framework
- Purpose: Extract names at odd indices and format them.
- Features:
- Uses Streams to filter names at odd indices.
- Formats the output as index. name.
- Methods Used:
IntStream.range,filter,mapToObj,collect.
- Purpose: Convert names to uppercase and sort in descending order.
- Features:
- Utilizes Streams for case conversion and sorting.
- Returns a sorted list in descending order.
- Methods Used:
map,sorted,collect.
- Purpose: Extract numbers from string arrays, sort, and return as a formatted string.
- Features:
- Parses and converts numbers from strings.
- Sorts numbers and returns them in comma-separated format.
- Methods Used:
flatMap,map,sorted,collect.
- Purpose: Generate an infinite stream of pseudo-random numbers.
- Features:
- Implements a linear congruential generator using Streams.
- Accepts parameters for seed (start value), a (multiplier), c (increment), and m (modulus).
- Methods Used:
Stream.iterate,map,limit.
- Purpose: Merge two streams by alternating elements.
- Features:
- Iterates over both streams simultaneously.
- Stops when one of the streams is exhausted.
- Methods Used:
Stream.iterate,flatMap,of,reduce,stream.