Free written guide · Start here
Java for beginners: your path to Spring Boot
Start with a small Java program, practise the language basics, then use them to build your first web API.
If you are looking for a Java beginner course, start by learning the language before adding a framework. This written guide gives you a first program, exercises and an order to follow. LeetJourney's beginner video course then picks up with Spring Boot 4 and a task manager REST API.
1. Run your first Java program
Install a Java Development Kit (JDK), which includes the tools to compile and run Java. Follow the official Java learning resources for installation and editor setup. When you start the Spring Boot course, use a JDK compatible with the project shown in the lessons.
Save this program in a file named HelloJava.java:
public class HelloJava {
public static void main(String[] args) {
String name = "Hassan";
int tasksCompleted = 3;
System.out.println(name + " completed " + tasksCompleted + " tasks");
}
}Open a terminal in the same folder and run:
javac HelloJava.java
java HelloJavaThe compiler turns your source into a class file, and the Java runtime executes it. You should see Hassan completed 3 tasks. The main method is the entry point. String holds text, int holds a whole number, and System.out.println prints a line.
Try it: change the name and task count, compile again, and check the output. Then add a second line that prints your next learning goal.
2. Practise variables, conditions, loops and methods
Learn to store a value, make a decision with if, repeat work with a loop, and extract repeated behaviour into a method. Understand the difference between returning a result and printing it: an API will need to return data to a caller, not just write it to your terminal.
Try it: write a method that receives a task count and returns whether the count is greater than zero. Call it with zero, one and five. Predict each result before running it.
3. Understand classes, objects and interfaces
A class describes data and behaviour; an object is an instance of that class. Create a Task class with a title and a completed flag. Use a constructor to give each task its initial values, then add a method to mark it complete. Create two tasks and check that changing one does not change the other.
An interface describes behaviour that different classes can implement. For example, a task store could save tasks in memory today and in a database later. This helps explain why Spring applications often pass dependencies through constructors: the caller can depend on a capability rather than create a specific implementation itself.
Once ordinary classes make sense, read Java records explained for another way to represent data. Learn the basics first; you do not need to use every language feature in your first project.
4. Store collections of data and handle mistakes
A List holds an ordered sequence, a Set holds unique values, and a Map associates keys with values. Start with a list of task titles. Save this example as TaskApp.java and run it using the same compile-and-run steps:
import java.util.ArrayList;
import java.util.List;
public class TaskApp {
public static void main(String[] args) {
List<String> tasks = new ArrayList<>();
tasks.add("Learn Java classes");
tasks.add("Build my first REST API");
for (String task : tasks) {
System.out.println(task);
}
}
}The type parameter in List<String> tells Java that this list contains strings. After you have a working loop, learn how Java streams express filtering and mapping. You should be able to explain the loop before replacing it.
Invalid input and missing data are part of normal programming. Practise reading an exception message and handling a problem where you can do something useful about it. Read checked and unchecked exceptions, then explore Optional for a result that may be absent.
Try it: add a third task, print the list size, and remove one task. Then replace the strings with Task objects. Explain why a list of titles cannot store a separate completion flag for each task as clearly as a list of Task objects.
5. Build a small Java task manager
Before adding HTTP or a database, build the smallest useful version in plain Java. Keep the task data separate from the code that prints it. Use these checks to decide whether you understand what you have built:
- Create a task with an ID, a title and a completed flag.
- Store several tasks and list them.
- Find a task by its ID and mark it complete.
- Reject an empty title with an explanation.
- Handle an ID that does not exist.
This version can keep tasks in memory, so losing them when the program stops is expected. That limitation gives you a concrete reason to learn persistence later. If you can change one of these behaviours without copying another tutorial, you are ready to start applying Java in a framework.
6. Turn your Java skills into a Spring Boot REST API
Java is the programming language. Spring provides application infrastructure such as dependency injection. Spring Boot helps configure and run a Spring application. In the beginner course, controllers expose task operations over HTTP, services hold application behaviour, and repositories handle persistence.
Start the free course when you can write a class, call a method, use a list and understand a simple exception. Keep the Spring bean explainer and constructor injection guide nearby when Spring begins creating and connecting your objects.
Common questions about learning Java
Can I learn Java without programming experience?
Yes. Start with running a program and changing small pieces of it. Work through conditions, loops, methods and classes before trying to build a web application. Use the official Java tutorials alongside the exercises here.
Is this a complete Java video course?
This page is a written starting guide with exercises and links to further reading. The free beginner video course on LeetJourney teaches Spring Boot and assumes basic Java knowledge.
How long should I spend on Java before Spring Boot?
Use the task manager checks above rather than a fixed number of days. If classes, methods and collections still feel unfamiliar, spend more time practising them. You can learn more advanced Java topics while building applications later.