|
1 | | -# Java Advanced: Stream API, Lambda, and Date Handling (Task 5) |
2 | | - |
3 | | -This repository contains Java programs demonstrating advanced Java concepts such as the Stream API, lambda expressions, and date handling with the `java.time` package. The project includes solutions to four tasks (Q1.1 to Q1.4) focusing on string manipulation, filtering, and age calculation. |
4 | | - |
5 | | -## Project Structure |
6 | | - |
7 | | -- **QuestionOne.java**: Converts a list of strings to uppercase using the Stream API (Q1.1). |
8 | | -- **QuestionTwo.java**: Filters out empty strings from a list and prints non-empty strings (Q1.2). |
9 | | -- **QuestionThree.java**: Filters student names starting with "A" using Stream API and lambda expressions (Q1.3). |
10 | | -- **QuestionFour.java**: Calculates a user's age based on their birthdate using `java.time.LocalDate` (Q1.4). |
11 | | -- **1.png, 2.png, 3.png, 4.png**: Screenshots of the code implementations for each task. |
12 | | - |
13 | | -## Tasks Overview |
14 | | - |
15 | | -### Q1.1: Convert Strings to Uppercase Using Stream API |
16 | | -- Uses the `Stream` API to convert a list of strings to uppercase. |
17 | | -- Input: `Stream names = Stream.of("aBc", "d", "ef")`. |
18 | | -- Output: A list of strings in uppercase (`ABC`, `D`, `EF`). |
19 | | - |
20 | | -### Q1.2: Filter Non-Empty Strings |
21 | | -- Checks a list of strings for empty elements and prints only the non-empty strings. |
22 | | -- Input: `List<String> strings = Arrays.asList("abc", "", "bc", "efg", "abcd", "", "jkl")`. |
23 | | -- Output: A list containing only non-empty strings (`abc`, `bc`, `efg`, `abcd`, `jkl`). |
24 | | - |
25 | | -### Q1.3: Filter Students Whose Names Start with "A" |
26 | | -- Simulates a classroom scenario with 10 students. |
27 | | -- Uses a `List` to store student names and the Stream API with a lambda expression to filter names starting with "A". |
28 | | -- Output: A list of student names starting with "A". |
29 | | - |
30 | | -### Q1.4: Age Calculator Using LocalDate |
31 | | -- Takes a user's birthdate as input in the format `yyyy-mm-dd` (e.g., `1990-05-15`). |
32 | | -- Calculates the user's age in years, months, and days using `java.time.LocalDate`. |
33 | | -- Example Output: `Your age is: 33 years, 4 months, and 13 days`. |
34 | | - |
35 | | -## How to Run |
36 | | - |
37 | | -1. **Clone the Repository**: |
38 | | - ```bash |
39 | | - git clone https://github.com/thesoulseizure/task-5.git |
40 | | - ``` |
41 | | -2. **Navigate to the Project Directory**: |
42 | | - ```bash |
43 | | - cd task-5 |
44 | | - ``` |
45 | | -3. **Compile the Java Files**: |
46 | | - ```bash |
47 | | - javac *.java |
48 | | - ``` |
49 | | -4. **Run the Desired Program**: |
50 | | - - For Q1.1: `java QuestionOne` |
51 | | - - For Q1.2: `java QuestionTwo` |
52 | | - - For Q1.3: `java QuestionThree` |
53 | | - - For Q1.4: `java QuestionFour` |
54 | | - |
55 | | -## Requirements |
56 | | - |
57 | | -- Java Development Kit (JDK) 8 or higher (JDK 8+ required for `java.time` package). |
58 | | -- A terminal or IDE to compile and run Java programs. |
59 | | - |
60 | | -## Screenshots |
61 | | - |
62 | | -The repository includes screenshots (1.png to 4.png) that show the code implementations for each task. Refer to these images to view the solutions visually. |
| 1 | + |
| 2 | +# 🚀 Java Advanced: Stream API, Lambda & Date Handling |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | +--- |
| 10 | + |
| 11 | +## 📌 Overview |
| 12 | + |
| 13 | +This repository contains **advanced Java programs** demonstrating: |
| 14 | + |
| 15 | +- ✔ Stream API |
| 16 | +- ✔ Lambda Expressions |
| 17 | +- ✔ `java.time` Date and Time Handling |
| 18 | +- ✔ Functional Processing |
| 19 | +- ✔ Real-world transformations & filtering |
| 20 | + |
| 21 | +The project includes **four tasks (Q1.1 – Q1.4)** focusing on stream operations, filtering collections, and age calculation using `LocalDate`. |
| 22 | + |
| 23 | +--- |
| 24 | + |
| 25 | +## 📁 Project Structure |
| 26 | + |
| 27 | +| File | Description | Category | |
| 28 | +|------|-------------|----------| |
| 29 | +| `src/QuestionOne.java` | Converts a list of strings to uppercase using Streams | Q1.1 | |
| 30 | +| `src/QuestionTwo.java` | Filters non‑empty strings from a list | Q1.2 | |
| 31 | +| `src/QuestionThree.java` | Filters names starting with 'A' using Stream + Lambda | Q1.3 | |
| 32 | +| `src/QuestionFour.java` | Calculates a user's age using `LocalDate` | Q1.4 | |
| 33 | +| `screenshots/1.png` | Screenshot for Q1.1 | Screenshot | |
| 34 | +| `screenshots/2.png` | Screenshot for Q1.2 | Screenshot | |
| 35 | +| `screenshots/3.png` | Screenshot for Q1.3 | Screenshot | |
| 36 | +| `screenshots/4.png` | Screenshot for Q1.4 | Screenshot | |
| 37 | + |
| 38 | +--- |
| 39 | + |
| 40 | +## 🧠 Task Breakdown (Grid) |
| 41 | + |
| 42 | +### 🔹 Q1.1 — Convert Strings to Uppercase |
| 43 | +Transforms a list of strings using the Stream API. |
| 44 | + |
| 45 | +### 🔹 Q1.2 — Filter Non‑Empty Strings |
| 46 | +Removes empty strings from a list using stream filtering. |
| 47 | + |
| 48 | +### 🔹 Q1.3 — Filter Students Starting with “A” |
| 49 | +Uses a lambda expression and stream filter operation. |
| 50 | + |
| 51 | +### 🔹 Q1.4 — Age Calculator Using LocalDate |
| 52 | +Parses a birthdate (YYYY‑MM‑DD) and computes age in **years, months, days**. |
| 53 | + |
| 54 | +--- |
| 55 | + |
| 56 | +## 🖼 Screenshots (Grid Layout) |
| 57 | + |
| 58 | +| Q1.1 | Q1.2 | |
| 59 | +|------|------| |
| 60 | +|  |  | |
| 61 | + |
| 62 | +| Q1.3 | Q1.4 | |
| 63 | +|------|------| |
| 64 | +|  |  | |
| 65 | + |
| 66 | +--- |
| 67 | + |
| 68 | +## ▶️ How to Run |
| 69 | + |
| 70 | +```bash |
| 71 | +git clone https://github.com/TheComputationalCore/java-advanced-streams-lambda-date.git |
| 72 | + |
| 73 | +cd java-advanced-streams-lambda-date |
| 74 | + |
| 75 | +javac src/*.java |
| 76 | +``` |
| 77 | + |
| 78 | +Run specific tasks: |
| 79 | + |
| 80 | +```bash |
| 81 | +java src/QuestionOne # Q1.1 |
| 82 | +java src/QuestionTwo # Q1.2 |
| 83 | +java src/QuestionThree # Q1.3 |
| 84 | +java src/QuestionFour # Q1.4 |
| 85 | +``` |
| 86 | + |
| 87 | +--- |
| 88 | + |
| 89 | +## 🛠 Tech Stack |
| 90 | + |
| 91 | +- **Java 17** |
| 92 | +- **Stream API** |
| 93 | +- **Lambda Expressions** |
| 94 | +- **java.time.LocalDate** |
| 95 | +- **Collections & Functional Programming** |
| 96 | + |
| 97 | +--- |
| 98 | + |
| 99 | +## 📦 Requirements |
| 100 | + |
| 101 | +- JDK 8 or higher (Java 17 recommended) |
| 102 | +- Terminal / IDE (IntelliJ, VS Code, Eclipse, etc.) |
| 103 | + |
| 104 | +--- |
| 105 | + |
| 106 | +## 🏷 Topics |
| 107 | + |
| 108 | +`java` • `streams` • `lambda` • `functional-programming` • `localdate` • `date-handling` |
| 109 | + |
| 110 | +--- |
| 111 | + |
| 112 | +## 📜 License |
| 113 | + |
| 114 | +Distributed under the **MIT License**. |
| 115 | + |
| 116 | +--- |
| 117 | + |
| 118 | +## ⭐ Contribute |
| 119 | + |
| 120 | +PRs are welcome! Feel free to enhance tasks or add new functional examples. |
0 commit comments