Simple To-Do Application with Java – A Beginner-Friendly CLI Project

📘 Simple To-Do Application with Java – A Beginner-Friendly CLI Project

Java remains one of the most searched and widely used programming languages in 2025. With its platform independence, strong type-safety, and object-oriented structure, Java is a top choice for building scalable, cross-platform applications. A simple console-based to-do list application is the perfect starting point for anyone learning Java. This project demonstrates real-world usage of Java syntax, conditionals, loops, user input handling, and collections.

📌 Why Java Is Ideal for CLI Applications

✔ Platform-independent using JVM
✔ Excellent for learning structured, OOP-based programming
✔ Includes built-in tools like Scanner, List, and System.out for I/O
✔ Easy to set up and run via terminal or IDE
✔ Perfect for beginners to practice logic and flow control

✅ Full Java To-Do App Code

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class ToDoApp {
    private static List<String> tasks = new ArrayList<>();

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        boolean running = true;

        while (running) {
            displayMenu();
            int choice = getChoice(scanner);

            switch (choice) {
                case 1:
                    addTask(scanner);
                    break;
                case 2:
                    markTaskComplete(scanner);
                    break;
                case 3:
                    displayTasks();
                    break;
                case 4:
                    running = false;
                    break;
                default:
                    System.out.println("Invalid choice. Please try again.");
            }
        }

        System.out.println("Goodbye!");
    }

    private static void displayMenu() {
        System.out.println("To-Do App Menu:");
        System.out.println("1. Add Task");
        System.out.println("2. Mark Task Complete");
        System.out.println("3. Display Tasks");
        System.out.println("4. Quit");
    }

    private static int getChoice(Scanner scanner) {
        System.out.print("Enter your choice: ");
        return scanner.nextInt();
    }

    private static void addTask(Scanner scanner) {
        scanner.nextLine(); // consume leftover newline
        System.out.print("Enter a new task: ");
        String task = scanner.nextLine().trim();
        if (!task.isEmpty()) {
            tasks.add(task);
            System.out.println("Task added successfully.");
        } else {
            System.out.println("Task cannot be empty.");
        }
    }

    private static void markTaskComplete(Scanner scanner) {
        displayTasks();
        System.out.print("Enter the task number to mark as complete: ");
        int taskNumber = scanner.nextInt() - 1;
        if (taskNumber >= 0 && taskNumber < tasks.size()) {
            tasks.set(taskNumber, "[COMPLETED] " + tasks.get(taskNumber));
            System.out.println("Task marked as complete.");
        } else {
            System.out.println("Invalid task number.");
        }
    }

    private static void displayTasks() {
        if (tasks.isEmpty()) {
            System.out.println("No tasks found.");
        } else {
            System.out.println("Current Tasks:");
            for (int i = 0; i < tasks.size(); i++) {
                System.out.println((i + 1) + ". " + tasks.get(i));
            }
        }
    }
}

✅ How This Java App Works

✔ Task Management Using List

✔ A List<String> stores all task descriptions
✔ Dynamic list allows for adding and updating tasks
✔ Tasks can be easily displayed with indexes

✔ Scanner for User Input

✔ Accepts user choices and task entries via keyboard
✔ Uses nextLine() and nextInt() for flexible input
✔ Helps handle multiple command options via menu

✔ Conditional Logic for App Navigation

✔ Uses while loop to keep app running until user exits
switch-case handles actions like add, mark, view, or quit
✔ Invalid inputs are gracefully managed with feedback messages

✔ Displaying Tasks with Indexes

✔ App prints numbered task list with line-by-line iteration
✔ Completed tasks are prefixed with [COMPLETED]
✔ Gives users visual feedback on task status

✅ SEO Keywords to Help Users Find This Tutorial

✔ Java CLI to-do list app
✔ beginner Java projects 2025
✔ task manager using Java console
✔ Java Scanner List example
✔ console-based Java application
✔ simple projects with Java code
✔ object-oriented project for Java learners

✅ Key Features of This Application

✔ Add Task
✔ Mark Task Complete
✔ Display All Tasks
✔ Exit Application Safely

✅ Benefits of Building This Java App

✔ Solidifies understanding of core Java syntax and structure
✔ Practices flow control, conditionals, and loop structures
✔ Shows real-world use of collections (ArrayList)
✔ Encourages clean function organization and reuse
✔ Lays groundwork for GUI, web, or database integration in future apps

✅ Enhancements You Can Add Next

✔ Allow deleting or editing tasks
✔ Save tasks to a file for persistence
✔ Filter tasks by status (completed, pending)
✔ Sort tasks alphabetically or by timestamp
✔ Build a graphical interface with JavaFX or Swing

✅ Best Practices for Java Console Apps

✔ Use clear prompts and feedback in console
✔ Validate input before processing
✔ Keep functions focused on a single responsibility
✔ Separate logic (task handling) from I/O (Scanner, System.out)
✔ Use comments to explain complex logic if needed

✅ Where This App Fits in the Learning Path

✔ Ideal follow-up to basic Java syntax and control flow
✔ Prepares you for Java OOP and design patterns
✔ Introduces app structure using methods and state
✔ Foundation for future GUI, Spring Boot, or REST API projects
✔ Enhances confidence before diving into frameworks or enterprise systems

🧠 Conclusion

A simple to-do list built with Java offers powerful insights into how to structure and manage code using one of the world’s most widely adopted languages. With just core libraries and standard syntax, you can build a fully functional, user-interactive console application that teaches data structures, conditionals, and method design. In 2025, Java continues to thrive in backend, mobile, and enterprise development—and this to-do app is your first step toward mastering it.

Comments