Java for beginners
406 subscribers
49 photos
29 links
Learn Java daily with bite-sized lessons, practical code examples, output previews, and fun quizzes.
Download Telegram
Here's your Telegram post for Day 30!

---

πŸŽ‰ **Congratulations on Reaching Day 30!** πŸŽ‰

You've made incredible progress in just thirty days, diving into Java fundamentals! πŸš€ Now it's time to consolidate all your learning with a final project. How about building a simple *Command-Line To-Do List Manager*? πŸ“ It's a fantastic way to apply your understanding of classes, objects, methods, `ArrayList`s, and user input. Let's review some core concepts and get you thinking!

Here’s a quick look at a basic `Task` class and how you might manage a list of them:

```java
import java.util.ArrayList;
import java.util.List;

// Represents a single To-Do item
class Task {
private String description;
private boolean isCompleted;

public Task(String description) {
this.description = description;
this.isCompleted = false; // By default, a new task is not completed
}

public String getDescription() {
return description;
}

public boolean isCompleted() {
return isCompleted;
}

public void markCompleted() {
this.isCompleted = true;
}

@Override
public String toString() {
return "[" + (isCompleted ? "βœ…" : "⏳") + "] " + description;
}
}

// Main class to demonstrate To-Do list management
public class Day30Review {
public static void main(String[] args) {
List<Task> myTasks = new ArrayList<>(); // Use ArrayList for dynamic size

System.out.println("--- Initial To-Do List ---");
myTasks.add(new Task("Learn Java basics"));
myTasks.add(new Task("Start final project idea"));
myTasks.add(new Task("Review OOP concepts"));

for (Task task : myTasks) {
System.out.println(task);
}

System.out.println("n--- Updating Task Status ---");
// Mark the first task as completed
if (!myTasks.isEmpty()) {
myTasks.get(0).markCompleted();
System.out.println("Marked '" + myTasks.get(0).getDescription() + "' as completed.");
}

System.out.println("n--- Updated To-Do List ---");
for (Task task : myTasks) {
System.out.println(task);
}
}
}
```

Output example:
```
--- Initial To-Do List ---
[⏳] Learn Java basics
[⏳] Start final project idea
[⏳] Review OOP concepts

--- Updating Task Status ---
Marked 'Learn Java basics' as completed.

--- Updated To-Do List ---
[βœ…] Learn Java basics
[⏳] Start final project idea
[⏳] Review OOP concepts
```

### Small Challenge:
Your challenge for your To-Do List Manager:
1. **Add User Input:** Implement `Scanner` to allow users to add new tasks.
2. **Remove Tasks:** Create a method that allows users to remove tasks by their index in the list.
3. **List by Status:** Add functionality to display *only* completed tasks or *only* pending tasks.

Ready to build something awesome? You've got this! πŸ’ͺ Don't forget to share your progress! #JavaLearning #Day30 #FinalProject #CodingChallenge

---