Eight beginner-friendly command-line projects for learning core Java, ordered from simple to more complex. Every project is a single, heavily commented source file with its own folder and README, so you can read it top to bottom as a lesson.
- JDK 17 or newer (the projects use records and switch expressions)
- Check with:
java -versionandjavac -version
No build tool or external library is needed. Open a terminal in a project folder and run:
javac ClassName.java
java ClassName| # | Project | Main concepts |
|---|---|---|
| 01 | Calculator | methods, switch, loops, input validation, exceptions |
| 02 | Number Guessing Game | Random, nested loops, conditionals, constants |
| 03 | Unit Converter | enums, switch expressions, pure functions, printf |
| 04 | Password Generator | SecureRandom, StringBuilder, collections, shuffling |
| 05 | Word Counter | file I/O, try-with-resources, strings, command-line args |
| 06 | To-Do List | classes and objects, encapsulation, ArrayList |
| 07 | Simple Quiz | records, lists, char arithmetic, scoring |
| 08 | Contact Book | Map/TreeMap, regex validation, sorting, layered design |
- Run it first. Play with the program as a user before reading any code.
- Read
mainfirst, then follow each method it calls. Use the comments as a guide. - Break it on purpose. Change a value, remove a check, and see which error appears and why.
- Do the "Try it yourself" extensions in each README. Writing new code is where the learning sticks.
- Rewrite from memory. After a few days, delete the file and rebuild the project from scratch.