Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nathanaelsantos/java-streams
This project is a Java application that explores the functionalities of the Java Stream API
https://github.com/nathanaelsantos/java-streams
Last synced: about 1 month ago
JSON representation
This project is a Java application that explores the functionalities of the Java Stream API
- Host: GitHub
- URL: https://github.com/nathanaelsantos/java-streams
- Owner: NathanaelSantos
- Created: 2024-05-18T05:33:17.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-05-22T04:46:25.000Z (8 months ago)
- Last Synced: 2024-05-22T05:35:56.303Z (8 months ago)
- Language: Java
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Java Stream API Exploration
This project is a simple Java application that explores the functionalities of the Java Stream API.
## Features
1. **Filtering and Collecting**: The application demonstrates how to filter a list of integers to get only the even numbers, both with a traditional for loop and with the Stream API.
2. **Finding Elements**: It shows how to find a specific element in a list of strings using the Stream API.
3. **Mapping and Collecting**: The application creates a list of `Fruit` objects, each with a name, category, and price. It then uses the Stream API to create a new list containing only the prices of the fruits.
4. **Mapping and Discounting**: It demonstrates how to apply a function to each element in a stream to create a new stream. In this case, it applies a 20% discount to the price of each fruit.
5. **Skipping and Limiting**: The application shows how to use the `skip` and `limit` operations to manipulate the size of the stream.
6. **Sorting**: Finally, it sorts the list of fruits in order from highest to lowest price.
## Running the Code
To run the code, simply execute the `Main` class. The results of each operation will be printed to the console.
## Conclusion
This project provides a clear and concise introduction to the Java Stream API, demonstrating its power and flexibility for manipulating collections of data. It serves as a great starting point for anyone looking to understand and utilize this feature of Java.