Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andreie91/java-lambda-expressions-exercises
A collection of problems which are solved with the use of lambda expressions, such as parsing a file and only saving objects which meet certain criteria.
https://github.com/andreie91/java-lambda-expressions-exercises
java lambda-expressions parsing
Last synced: 11 days ago
JSON representation
A collection of problems which are solved with the use of lambda expressions, such as parsing a file and only saving objects which meet certain criteria.
- Host: GitHub
- URL: https://github.com/andreie91/java-lambda-expressions-exercises
- Owner: AndreiE91
- Created: 2023-05-26T16:09:24.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-06T12:28:09.000Z (12 months ago)
- Last Synced: 2024-11-14T11:12:00.932Z (2 months ago)
- Topics: java, lambda-expressions, parsing
- Language: Java
- Homepage:
- Size: 43.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Lambda Expressions in Problem Solving
![Lambda_Expressions](images/Lambda_img.png)
## Overview
This repository contains a collection of problems solved using lambda expressions in various scenarios, primarily focusing on parsing files and filtering CSV objects based on specific criteria. Lambda expressions provide concise syntax for writing inline functions, making them particularly useful for tasks involving data manipulation and filtering.
## Problem Statements
### Problem 1: CSV File Parsing and Filtering
#### Description:
- Given a CSV file containing data records, parse the file and filter objects based on specific criteria.
- Criteria may include conditions such as filtering records based on certain attributes, values, or patterns.#### Solution Approach:
- Utilize lambda expressions to define filtering criteria inline.
- Use Java's Stream API to read and process data from the CSV file.
- Apply lambda expressions as predicates to filter objects that meet the specified criteria.
#### Example Code:
```java
// Sample code demonstrating CSV file parsing and filtering using lambda expressions
public class CsvParser {
public static void main(String[] args) {
// Read CSV file
List csvObjects = readCsvFile("data.csv");
// Filter CSV objects based on criteria using lambda expressions
List filteredObjects = csvObjects.stream()
.filter(obj -> obj.getCriteria().matches("regex pattern"))
.collect(Collectors.toList());
// Process filtered objects
filteredObjects.forEach(System.out::println);
}
}
```### Problem 2: Display only names of people who work during certain hour interval and drink coffee at breakfast
Solution to similar type of problems available in code, sample data file also available in repository files as `Activities.txt`
## Usage
To run the sample code, simply execute the `Main` class. Ensure you have Java installed on your system.
## Cloning Instructions
To clone this repository, run the following command in your terminal:
```bash
git clone https://github.com/AndreiE91/Java-Lambda-Expressions-Exercises.git
```